lib/pwn/plugins/baresip.rb in pwn-0.4.517 vs lib/pwn/plugins/baresip.rb in pwn-0.4.518
- old
+ new
@@ -289,10 +289,14 @@
# target_num: 'Required - destination number to derive source number',
# src_num_rules: 'Optional - Comma-delimited list of rules for src_num format (i.e. self, same_country, same_area, and/or same_prefix [Defaults to random src_num w/ same length as target_num])'
# )
public_class_method def self.apply_src_num_rules(opts = {})
+ config_root = opts[:config_root] if Dir.exist?(
+ opts[:config_root].to_s
+ )
+ config_root ||= "#{Dir.home}/.baresip"
src_num_rules = opts[:src_num_rules]
target_num = opts[:target_num]
src_num_rules_arr = []
if src_num_rules
@@ -345,12 +349,21 @@
suffix = format('%0.4s', Random.rand(0..9999))
src_num = "#{country}#{area}#{prefix}#{suffix}"
src_num = target_num if src_num_rules_arr.include?(:self)
# TODO: Update ~/.baresip/accounts to apply source number
- # config_root = baresip_obj[:config_root]
- # config = "#{config_root}/config"
+ sip_accounts_path = "#{config_root}/accounts"
+ updated_account_content = ''
+ File.read(sip_accounts_path).each_line do |line|
+ this_account_line = line
+ if line.match?(/^<sip:.+@.+>/)
+ sip_account_to_keep = this_account_line.split('@').last
+ this_account_line = "<sip:#{src_num}@#{sip_account_to_keep}"
+ end
+ updated_account_content = "#{updated_account_content}#{this_account_line}"
+ end
+ File.write(sip_accounts_path, updated_account_content)
src_num
rescue StandardError => e
raise e
end
@@ -364,10 +377,16 @@
# sox_bin: 'Optional - Path to SoX Binary, the Swiss Army knife of Audio (Defaults to /usr/bin/sox)'
# )
public_class_method def self.recon(opts = {})
baresip_bin = opts[:baresip_bin]
+
+ config_root = opts[:config_root] if Dir.exist?(
+ opts[:config_root].to_s
+ )
+ config_root ||= "#{Dir.home}/.baresip"
+
session_root = opts[:session_root]
session_root ||= Dir.pwd
target_file = opts[:target_file]
randomize = opts[:randomize]
src_num_rules = opts[:src_num_rules]
@@ -412,9 +431,10 @@
# Change to session_root _before_ starting to ensure
# wav files are stored in the proper location
Dir.chdir(session_root)
src_num = apply_src_num_rules(
+ config_root: config_root,
target_num: target_num,
src_num_rules: src_num_rules
)
call_info_hash = {}