diff --git a/lib/msf/base.rb b/lib/msf/base.rb index 693ccb97ff..bf264377c8 100644 --- a/lib/msf/base.rb +++ b/lib/msf/base.rb @@ -22,20 +22,19 @@ require 'msf/core' require 'msf/base/config' require 'msf/base/logging' -module Msf - # Simple wrapper - autoload :Simple, 'msf/base/simple' +# Simple wrapper +require 'msf/base/simple' - # Sessions - autoload :Sessions, 'msf/base/sessions' +# Sessions +require 'msf/base/sessions/command_shell' +require 'msf/base/sessions/tty' - # Serialization - autoload :Serializer, 'msf/base/serializer/readable_text' +# Serialization +require 'msf/base/serializer/readable_text' - # Persistent Storage - autoload :PersistentStorage, 'msf/base/persistent_storage' +# Persistent Storage +require 'msf/base/persistent_storage' - # Utilities - autoload :Util, 'msf/util' -end +# Utilities +require 'msf/util' diff --git a/lib/msf/base/logging.rb b/lib/msf/base/logging.rb index 6c59da7d5d..790057520f 100644 --- a/lib/msf/base/logging.rb +++ b/lib/msf/base/logging.rb @@ -1,5 +1,4 @@ require 'rex' -require 'rex/logging' require 'msf/base' module Msf diff --git a/lib/msf/base/sessions.rb b/lib/msf/base/sessions.rb deleted file mode 100644 index 39ab68b48e..0000000000 --- a/lib/msf/base/sessions.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Msf -module Sessions - autoload :CommandShell, 'msf/base/sessions/command_shell' - autoload :CommandShellWindows, 'msf/base/sessions/command_shell' - autoload :CommandShellUnix, 'msf/base/sessions/command_shell' - - autoload :Meterpreter, 'msf/base/sessions/meterpreter' - autoload :Meterpreter_Java_Java, 'msf/base/sessions/meterpreter_java' - autoload :Meterpreter_Php_Php, 'msf/base/sessions/meterpreter_php' - autoload :Meterpreter_x64_Win, 'msf/base/sessions/meterpreter_x64_win' - autoload :Meterpreter_x86_BSD, 'msf/base/sessions/meterpreter_x86_bsd' - autoload :Meterpreter_x86_Linux, 'msf/base/sessions/meterpreter_x86_linux' - autoload :Meterpreter_x86_Win, 'msf/base/sessions/meterpreter_x86_win' - - autoload :VncInject, 'msf/base/sessions/vncinject' - - autoload :TTY, 'msf/base/sessions/tty' -end -end diff --git a/lib/msf/base/sessions/meterpreter.rb b/lib/msf/base/sessions/meterpreter.rb index 1391e8a591..be9971aecd 100644 --- a/lib/msf/base/sessions/meterpreter.rb +++ b/lib/msf/base/sessions/meterpreter.rb @@ -4,6 +4,7 @@ require 'msf/base' require 'msf/base/sessions/scriptable' +require 'rex/post/meterpreter' module Msf module Sessions diff --git a/lib/msf/base/sessions/vncinject.rb b/lib/msf/base/sessions/vncinject.rb index 1735cb8143..af451dac01 100644 --- a/lib/msf/base/sessions/vncinject.rb +++ b/lib/msf/base/sessions/vncinject.rb @@ -1,4 +1,5 @@ require 'msf/base' +require 'rex/services/local_relay' module Msf module Sessions diff --git a/lib/msf/base/simple.rb b/lib/msf/base/simple.rb index ece2728af4..2a1e8cdc81 100644 --- a/lib/msf/base/simple.rb +++ b/lib/msf/base/simple.rb @@ -1,17 +1,15 @@ -module Msf::Simple - # Buffer management - autoload :Buffer, 'msf/base/simple/buffer' - autoload :Statistics, 'msf/base/simple/statistics' +# Buffer management +require 'msf/base/simple/buffer' +require 'msf/base/simple/statistics' - # Simplified module interfaces - autoload :Module, 'msf/base/simple/module' - autoload :Encoder, 'msf/base/simple/encoder' - autoload :Exploit, 'msf/base/simple/exploit' - autoload :Nop, 'msf/base/simple/nop' - autoload :Payload, 'msf/base/simple/payload' - autoload :Auxiliary, 'msf/base/simple/auxiliary' - autoload :Post, 'msf/base/simple/post' +# Simplified module interfaces +require 'msf/base/simple/module' +require 'msf/base/simple/encoder' +require 'msf/base/simple/exploit' +require 'msf/base/simple/nop' +require 'msf/base/simple/payload' +require 'msf/base/simple/auxiliary' +require 'msf/base/simple/post' - # Simplified framework interface - autoload :Framework, 'msf/base/simple/framework' -end +# Simplified framework interface +require 'msf/base/simple/framework' diff --git a/lib/msf/core.rb b/lib/msf/core.rb index ddb6755a97..e49369863a 100644 --- a/lib/msf/core.rb +++ b/lib/msf/core.rb @@ -14,39 +14,10 @@ require 'msf/sanity' # The framework-core depends on Rex require 'rex' +require 'rex/ui' -# Set the log source, and initialize demand-loaded requires module Msf LogSource = "core" - - # Event subscriber interfaces - autoload :UiEventSubscriber, 'msf/events' - - # Wrappers - autoload :EncodedPayload, 'msf/core/encoded_payload' - - # Pseudo-modules - autoload :Handler, 'msf/core/handler' - - # Mixins - autoload :Encoder, 'msf/core/encoder' - autoload :EncoderState, 'msf/core/encoder' - autoload :Auxiliary, 'msf/core/auxiliary' - autoload :Nop, 'msf/core/nop' - autoload :Payload, 'msf/core/payload' - autoload :ExploitEvent, 'msf/core/exploit' - autoload :Exploit, 'msf/core/exploit' - autoload :Post, 'msf/core/post' - - # Drivers - autoload :ExploitDriver, 'msf/core/exploit_driver' - - # Framework context and core classes - autoload :Framework, 'msf/core/framework' - - # Session stuff - autoload :Session, 'msf/core/session' - autoload :SessionEvent, 'msf/core/session' end # General @@ -55,5 +26,35 @@ require 'msf/core/exceptions' require 'msf/core/data_store' require 'msf/core/option_container' +# Event subscriber interfaces +require 'msf/events' + +# Framework context and core classes +require 'msf/core/framework' +require 'msf/core/db_manager' +require 'msf/core/event_dispatcher' +require 'msf/core/module_manager' +require 'msf/core/plugin_manager' +require 'msf/core/session' +require 'msf/core/session_manager' + + +# Wrappers +require 'msf/core/encoded_payload' + +# Pseudo-modules +require 'msf/core/handler' + # Modules require 'msf/core/module' +require 'msf/core/encoder' +require 'msf/core/auxiliary' +require 'msf/core/exploit' +require 'msf/core/nop' +require 'msf/core/payload' +require 'msf/core/post' + + +# Drivers +require 'msf/core/exploit_driver' + diff --git a/lib/msf/core/auxiliary/mixins.rb b/lib/msf/core/auxiliary/mixins.rb index 89aac26237..b1bdd02e01 100644 --- a/lib/msf/core/auxiliary/mixins.rb +++ b/lib/msf/core/auxiliary/mixins.rb @@ -5,35 +5,17 @@ # # Auxiliary mixins # -module Msf -class Auxiliary - # Main types of auxiliary modules - autoload :AuthBrute, 'msf/core/auxiliary/auth_brute' - autoload :Dos, 'msf/core/auxiliary/dos' - autoload :Fuzzer, 'msf/core/auxiliary/fuzzer' - autoload :Scanner, 'msf/core/auxiliary/scanner' - autoload :Timed, 'msf/core/auxiliary/timed' +require 'msf/core/auxiliary/auth_brute' +require 'msf/core/auxiliary/dos' +require 'msf/core/auxiliary/fuzzer' +require 'msf/core/auxiliary/report' +require 'msf/core/auxiliary/scanner' +require 'msf/core/auxiliary/timed' +require 'msf/core/auxiliary/wmapmodule' +require 'msf/core/auxiliary/crawler' - # WMAP - autoload :WMAPModule, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPScanSSL, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPScanFile, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPScanDir, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPScanServer, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPScanQuery, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPScanUniqueQuery, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPScanGeneric, 'msf/core/auxiliary/wmapmodule' - autoload :WMAPCrawler, 'msf/core/auxiliary/wmapmodule' - autoload :HttpCrawler, 'msf/core/auxiliary/crawler' - - # Miscallaneous - autoload :Report, 'msf/core/auxiliary/report' - autoload :CommandShell, 'msf/core/auxiliary/commandshell' - autoload :Nmap, 'msf/core/auxiliary/nmap' - - # Protocol augmenters for Aux modules - autoload :Login, 'msf/core/auxiliary/login' - autoload :RServices, 'msf/core/auxiliary/rservices' - autoload :Cisco, 'msf/core/auxiliary/cisco' -end -end +require 'msf/core/auxiliary/commandshell' +require 'msf/core/auxiliary/login' +require 'msf/core/auxiliary/rservices' +require 'msf/core/auxiliary/cisco' +require 'msf/core/auxiliary/nmap' diff --git a/lib/msf/core/auxiliary/nmap.rb b/lib/msf/core/auxiliary/nmap.rb index ee0b9960ef..0253a63850 100644 --- a/lib/msf/core/auxiliary/nmap.rb +++ b/lib/msf/core/auxiliary/nmap.rb @@ -1,3 +1,4 @@ +require 'rex/parser/nmap_xml' require 'open3' module Msf diff --git a/lib/msf/core/db.rb b/lib/msf/core/db.rb index 7e72ee4942..d9b05afcde 100644 --- a/lib/msf/core/db.rb +++ b/lib/msf/core/db.rb @@ -1,10 +1,16 @@ - -autoload :FileUtils, 'fileutils' -autoload :Zip, 'zip' -autoload :URI, 'uri' -autoload :PacketFu, 'packetfu' - +require 'rex/parser/nmap_xml' +require 'rex/parser/nexpose_xml' +require 'rex/parser/retina_xml' +require 'rex/parser/netsparker_xml' +require 'rex/parser/nessus_xml' +require 'rex/parser/ip360_xml' +require 'rex/parser/ip360_aspl_xml' +require 'rex/socket' +require 'zip' +require 'packetfu' +require 'uri' require 'tmpdir' +require 'fileutils' module Msf @@ -2064,7 +2070,7 @@ class DBManager end # Returns one of: :nexpose_simplexml :nexpose_rawxml :nmap_xml :openvas_xml - # :nessus_xml :nessus_xml_v2 :qualys_scan_xml, :qualys_asset_xml, :msf_xml :nessus_nbe :amap_mlog + # :nessus_xml :nessus_xml_v2 :qualys_xml :msf_xml :nessus_nbe :amap_mlog # :amap_log :ip_list, :msf_zip, :libpcap # If there is no match, an error is raised instead. def import_filetype_detect(data) @@ -2134,11 +2140,8 @@ class DBManager @import_filedata[:type] = "Nessus XML (v2)" return :nessus_xml_v2 when "SCAN" - @import_filedata[:type] = "Qualys Scan XML" - return :qualys_scan_xml - when "ASSET_DATA_REPORT" - @import_filedata[:type] = "Qualys Asset XML" - return :qualys_asset_xml + @import_filedata[:type] = "Qualys XML" + return :qualys_xml when /MetasploitExpressV[1234]/ @import_filedata[:type] = "Metasploit XML" return :msf_xml @@ -4378,114 +4381,10 @@ class DBManager REXML::Document.parse_stream(data, parser) end - def find_qualys_asset_vuln_refs(doc) - vuln_refs = {} - doc.elements.each("/ASSET_DATA_REPORT/GLOSSARY/VULN_DETAILS_LIST/VULN_DETAILS") do |vuln| - next unless vuln.elements['QID'] && vuln.elements['QID'].first - qid = vuln.elements['QID'].first.to_s - vuln_refs[qid] ||= [] - if vuln.elements["CVE_ID_LIST/CVE_ID/ID"] - vuln.elements["CVE_ID_LIST/CVE_ID/ID"].each do |ref| - next unless ref - next unless ref.to_s[/^C..-[0-9\-]{9}/] - vuln_refs[qid] << ref.to_s.gsub(/^C../, "CVE") - end - end - if vuln.elements["BUGTRAQ_ID_LIST/BUGTRAQ_ID/ID"] - vuln.elements["BUGTRAQ_ID_LIST/BUGTRAQ_ID/ID"].each do |ref| - next unless ref - next unless ref.to_s[/^[0-9]{1,9}/] - vuln_refs[qid] << "BID-#{ref}" - end - end - end - return vuln_refs - end - - # Pull out vulnerabilities that have at least one matching - # ref -- many "vulns" are not vulns, just audit information. - def find_qualys_asset_vulns(host,wspace,hobj,vuln_refs,&block) - host.elements.each("VULN_INFO_LIST/VULN_INFO") do |vi| - next unless vi.elements["QID"] - vi.elements.each("QID") do |qid| - next if vuln_refs[qid.text].nil? || vuln_refs[qid.text].empty? - handle_qualys(wspace, hobj, nil, nil, qid.text, nil, vuln_refs[qid.text], nil) - end - end - end - - # Takes QID numbers and finds the discovered services in - # a qualys_asset_xml. - def find_qualys_asset_ports(i,host,wspace,hobj) - return unless (i == 82023 || i == 82004) - proto = i == 82023 ? 'tcp' : 'udp' - qid = host.elements["VULN_INFO_LIST/VULN_INFO/QID[@id='qid_#{i}']"] - qid_result = qid.parent.elements["RESULT[@format='table']"] if qid - hports = qid_result.first.to_s if qid_result - if hports - hports.scan(/([0-9]+)\t(.*?)\t.*?\t([^\t\n]*)/) do |match| - if match[2] == nil or match[2].strip == 'unknown' - name = match[1].strip - else - name = match[2].strip - end - handle_qualys(wspace, hobj, match[0].to_s, proto, 0, nil, nil, name) - end - end - end - # - # Import Qualys's Asset Data Report format - # - def import_qualys_asset_xml(args={}, &block) - data = args[:data] - wspace = args[:wspace] || workspace - bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : [] - doc = rexmlify(data) - vuln_refs = find_qualys_asset_vuln_refs(doc) - - # 2nd pass, actually grab the hosts. - doc.elements.each("/ASSET_DATA_REPORT/HOST_LIST/HOST") do |host| - hobj = nil - addr = host.elements["IP"].text if host.elements["IP"] - next unless validate_ips(addr) - if bl.include? addr - next - else - yield(:address,addr) if block - end - hname = ( # Prefer NetBIOS over DNS - (host.elements["NETBIOS"].text if host.elements["NETBIOS"]) || - (host.elements["DNS"].text if host.elements["DNS"]) || - "" ) - hobj = report_host(:workspace => wspace, :host => addr, :name => hname, :state => Msf::HostState::Alive) - report_import_note(wspace,hobj) - - if host.elements["OPERATING_SYSTEM"] - hos = host.elements["OPERATING_SYSTEM"].text - report_note( - :workspace => wspace, - :host => hobj, - :type => 'host.os.qualys_fingerprint', - :data => { :os => hos } - ) - end - - # Report open ports. - find_qualys_asset_ports(82023,host,wspace,hobj) # TCP - find_qualys_asset_ports(82004,host,wspace,hobj) # UDP - - # Report vulns - find_qualys_asset_vulns(host,wspace,hobj,vuln_refs,&block) - - end # host - - end - + # Import Qualys' xml output # - # Import Qualys' Scan xml output - # - def import_qualys_scan_xml_file(args={}) + def import_qualys_xml_file(args={}) filename = args[:filename] wspace = args[:wspace] || workspace @@ -4493,10 +4392,10 @@ class DBManager ::File.open(filename, 'rb') do |f| data = f.read(f.stat.size) end - import_qualys_scan_xml(args.merge(:data => data)) + import_qualys_xml(args.merge(:data => data)) end - def import_qualys_scan_xml(args={}, &block) + def import_qualys_xml(args={}, &block) data = args[:data] wspace = args[:wspace] || workspace bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : [] @@ -4950,7 +4849,7 @@ protected # def handle_qualys(wspace, hobj, port, protocol, qid, severity, refs, name=nil) addr = hobj.address - port = port.to_i if port + port = port.to_i info = { :workspace => wspace, :host => hobj, :port => port, :proto => protocol } if name and name != 'unknown' diff --git a/lib/msf/core/exploit.rb b/lib/msf/core/exploit.rb index ddb7945ccc..7942e66475 100644 --- a/lib/msf/core/exploit.rb +++ b/lib/msf/core/exploit.rb @@ -156,48 +156,6 @@ class Exploit < Msf::Module ### class Remote < Exploit - # Protocol - layer 3 - autoload :Ip, 'msf/core/exploit/ip' - autoload :Ipv6, 'msf/core/exploit/ipv6' - # Protocol - layer 4 - autoload :Tcp, 'msf/core/exploit/tcp' - autoload :TcpServer, 'msf/core/exploit/tcp' - autoload :Udp, 'msf/core/exploit/udp' - # Protocol - layer 5 - autoload :Ftp, 'msf/core/exploit/ftp' - autoload :FtpServer, 'msf/core/exploit/ftpserver' - autoload :Telnet, 'msf/core/exploit/telnet' - autoload :HttpClient, 'msf/core/exploit/http/client' - autoload :HttpServer, 'msf/core/exploit/http/server' - autoload :Smtp, 'msf/core/exploit/smtp' - autoload :Imap, 'msf/core/exploit/imap' - autoload :Pop2, 'msf/core/exploit/pop2' - autoload :SMTPDeliver, 'msf/core/exploit/smtp_deliver' - autoload :SMB, 'msf/core/exploit/smb' - autoload :SMBServer, 'msf/core/exploit/smb' - autoload :DCERPC, 'msf/core/exploit/dcerpc' - autoload :SunRPC, 'msf/core/exploit/sunrpc' - - autoload :MSSQL, 'msf/core/exploit/mssql' - autoload :MSSQL_COMMANDS, 'msf/core/exploit/mssql_commands' - autoload :MSSQL_SQLI, 'msf/core/exploit/mssql_sqli' - - autoload :MYSQL, 'msf/core/exploit/mysql' - autoload :TNS, 'msf/core/exploit/tns' - autoload :DB2, 'msf/core/exploit/db2' - autoload :Postgres, 'msf/core/exploit/postgres' - - autoload :SNMPClient, 'msf/core/exploit/snmp' - autoload :Arkeia, 'msf/core/exploit/arkeia' - autoload :NDMP, 'msf/core/exploit/ndmp' - - autoload :WDBRPC, 'msf/core/exploit/wdbrpc' - autoload :WDBRPC_Client, 'msf/core/exploit/wdbrpc_client' - - autoload :BrowserAutopwn, 'msf/core/exploit/browser_autopwn' - - autoload :Dialup, 'msf/core/exploit/dialup' - # # Initializes the socket array. # diff --git a/lib/msf/core/exploit/capture.rb b/lib/msf/core/exploit/capture.rb index 23d5d4399b..21c3a1e8e6 100644 --- a/lib/msf/core/exploit/capture.rb +++ b/lib/msf/core/exploit/capture.rb @@ -205,7 +205,7 @@ module Exploit::Capture capture_file.setfilter(filter) if filter while (pkt = capture_file.next) do pcap.inject(pkt) - Kernel.select(nil, nil, nil, (delay * 1.0)/1000) + Kernel.select(nil, nil, nil, delay/1000) end GC.start end @@ -373,13 +373,9 @@ module Exploit::Capture end def check_pcaprub_loaded - if not @pcaprub_loaded + unless @pcaprub_loaded print_status("The Pcaprub module is not available: #{@pcaprub_error}") raise RuntimeError, "Pcaprub not available" - #Those methods have been added later - elsif (not Pcap.respond_to? "lookupaddrs") - print_status("The Pcaprub module is not up-to-date") - raise RuntimeError, "The Pcaprub module is missing some functions" else true end diff --git a/lib/msf/core/exploit/cmdstager.rb b/lib/msf/core/exploit/cmdstager.rb index e3d56a5dda..65967cd4dc 100644 --- a/lib/msf/core/exploit/cmdstager.rb +++ b/lib/msf/core/exploit/cmdstager.rb @@ -2,6 +2,7 @@ # $Id$ ## +require 'rex/exploitation/cmdstager' require 'msf/core/exploit/exe' module Msf diff --git a/lib/msf/core/exploit/cmdstager_tftp.rb b/lib/msf/core/exploit/cmdstager_tftp.rb index 57af7270cc..083f80b92e 100644 --- a/lib/msf/core/exploit/cmdstager_tftp.rb +++ b/lib/msf/core/exploit/cmdstager_tftp.rb @@ -2,6 +2,7 @@ # $Id$ ## +require 'rex/text' require 'msf/core/exploit/tftp' require 'msf/core/exploit/cmdstager' diff --git a/lib/msf/core/exploit/cmdstager_vbs.rb b/lib/msf/core/exploit/cmdstager_vbs.rb index 54bc522cc3..879bc214dc 100644 --- a/lib/msf/core/exploit/cmdstager_vbs.rb +++ b/lib/msf/core/exploit/cmdstager_vbs.rb @@ -13,8 +13,6 @@ module Msf ### module Exploit::CmdStagerVBS - autoload :ADODB, 'msf/core/exploit/cmdstager_vbs_adodb' - include Msf::Exploit::CmdStager def initialize(info = {}) diff --git a/lib/msf/core/exploit/dcerpc.rb b/lib/msf/core/exploit/dcerpc.rb index 317b508b5e..2bb31503ea 100644 --- a/lib/msf/core/exploit/dcerpc.rb +++ b/lib/msf/core/exploit/dcerpc.rb @@ -1,3 +1,5 @@ +require 'rex/proto/dcerpc' +require 'rex/encoder/ndr' require 'msf/core/exploit/dcerpc_epm' require 'msf/core/exploit/dcerpc_mgmt' require 'msf/core/exploit/dcerpc_lsa' diff --git a/lib/msf/core/exploit/dhcp.rb b/lib/msf/core/exploit/dhcp.rb index d9e8a1bcc7..a74c0cbe66 100644 --- a/lib/msf/core/exploit/dhcp.rb +++ b/lib/msf/core/exploit/dhcp.rb @@ -2,6 +2,7 @@ # $Id$ ## +require 'rex/proto/dhcp' module Msf diff --git a/lib/msf/core/exploit/egghunter.rb b/lib/msf/core/exploit/egghunter.rb index c3b9005f82..702dfce174 100644 --- a/lib/msf/core/exploit/egghunter.rb +++ b/lib/msf/core/exploit/egghunter.rb @@ -1,5 +1,6 @@ # $Id$ +require 'rex/exploitation/egghunter' module Msf diff --git a/lib/msf/core/exploit/http/client.rb b/lib/msf/core/exploit/http/client.rb index e2f20fd78d..7fb23e4ec0 100644 --- a/lib/msf/core/exploit/http/client.rb +++ b/lib/msf/core/exploit/http/client.rb @@ -1,4 +1,8 @@ require 'digest' +require 'rex/proto/ntlm/crypt' +require 'rex/proto/ntlm/constants' +require 'rex/proto/ntlm/utils' +require 'rex/proto/ntlm/exceptions' module Msf ### diff --git a/lib/msf/core/exploit/http/server.rb b/lib/msf/core/exploit/http/server.rb index dfbbe6f7b8..a01fa500a4 100644 --- a/lib/msf/core/exploit/http/server.rb +++ b/lib/msf/core/exploit/http/server.rb @@ -1,3 +1,7 @@ +require 'rex/service_manager' +require 'rex/exploitation/obfuscatejs' +require 'rex/exploitation/encryptjs' +require 'rex/exploitation/heaplib' module Msf @@ -12,7 +16,6 @@ module Exploit::Remote::HttpServer include Msf::Exploit::Remote::TcpServer include Msf::Auxiliary::Report - def initialize(info = {}) super diff --git a/lib/msf/core/exploit/kernel_mode.rb b/lib/msf/core/exploit/kernel_mode.rb index 211f877d42..dea13912d8 100644 --- a/lib/msf/core/exploit/kernel_mode.rb +++ b/lib/msf/core/exploit/kernel_mode.rb @@ -1,5 +1,6 @@ module Msf +require 'rex/payloads/win32/kernel' module Exploit::KernelMode diff --git a/lib/msf/core/exploit/mixins.rb b/lib/msf/core/exploit/mixins.rb index 3bd0463635..bb7c876a40 100644 --- a/lib/msf/core/exploit/mixins.rb +++ b/lib/msf/core/exploit/mixins.rb @@ -3,56 +3,84 @@ # All exploit mixins should be added to the list below # -class Msf::Exploit +# Behavior +require 'msf/core/exploit/brute' +require 'msf/core/exploit/brutetargets' +require 'msf/core/exploit/browser_autopwn' - # Behavior - autoload :Brute, 'msf/core/exploit/brute' - autoload :BruteTargets, 'msf/core/exploit/brutetargets' +# Payload +require 'msf/core/exploit/egghunter' +require 'msf/core/exploit/omelet' +require 'msf/core/exploit/seh' +require 'msf/core/exploit/kernel_mode' +require 'msf/core/exploit/exe' - # Payload - autoload :Egghunter, 'msf/core/exploit/egghunter' - autoload :Omelet, 'msf/core/exploit/omelet' - autoload :Seh, 'msf/core/exploit/seh' - autoload :KernelMode, 'msf/core/exploit/kernel_mode' - autoload :EXE, 'msf/core/exploit/exe' +# CmdStagers +require 'msf/core/exploit/cmdstager' +require 'msf/core/exploit/cmdstager_vbs' +require 'msf/core/exploit/cmdstager_vbs_adodb' +require 'msf/core/exploit/cmdstager_debug_write' +require 'msf/core/exploit/cmdstager_debug_asm' +require 'msf/core/exploit/cmdstager_tftp' - # CmdStagers - autoload :CmdStager, 'msf/core/exploit/cmdstager' - autoload :CmdStagerVBS, 'msf/core/exploit/cmdstager_vbs' - autoload :CmdStagerDebugWrite, 'msf/core/exploit/cmdstager_debug_write' - autoload :CmdStagerDebugAsm, 'msf/core/exploit/cmdstager_debug_asm' - autoload :CmdStagerTFTP, 'msf/core/exploit/cmdstager_tftp' +# Protocol +require 'msf/core/exploit/tcp' +require 'msf/core/exploit/udp' +require 'msf/core/exploit/ip' +require 'msf/core/exploit/ipv6' +require 'msf/core/exploit/dhcp' +require 'msf/core/exploit/ntlm' +require 'msf/core/exploit/smb' +require 'msf/core/exploit/ftp' +require 'msf/core/exploit/tftp' +require 'msf/core/exploit/telnet' +require 'msf/core/exploit/ftpserver' +require 'msf/core/exploit/http/client' +require 'msf/core/exploit/http/server' +require 'msf/core/exploit/smtp' +require 'msf/core/exploit/dcerpc' +require 'msf/core/exploit/sunrpc' +require 'msf/core/exploit/mssql' +require 'msf/core/exploit/mssql_commands' +require 'msf/core/exploit/mssql_sqli' +require 'msf/core/exploit/mysql' +require 'msf/core/exploit/snmp' +require 'msf/core/exploit/arkeia' +require 'msf/core/exploit/ndmp' +require 'msf/core/exploit/imap' +require 'msf/core/exploit/smtp_deliver' +require 'msf/core/exploit/pop2' +require 'msf/core/exploit/tns' +require 'msf/core/exploit/db2' +require 'msf/core/exploit/postgres' +require 'msf/core/exploit/wdbrpc' +require 'msf/core/exploit/wdbrpc_client' - # Protocol utils - autoload :NTLM, 'msf/core/exploit/ntlm' - # Protocol - layer 2 - autoload :DHCPServer, 'msf/core/exploit/dhcp' - autoload :TFTPServer, 'msf/core/exploit/tftp' +# Telephony +require 'msf/core/exploit/dialup' +require 'msf/core/exploit/dect_coa' - # Telephony - autoload :DECT_COA, 'msf/core/exploit/dect_coa' +# Networks +require 'msf/core/exploit/lorcon' +require 'msf/core/exploit/lorcon2' +require 'msf/core/exploit/capture' - # Networks - autoload :Lorcon, 'msf/core/exploit/lorcon' - autoload :Lorcon2, 'msf/core/exploit/lorcon2' - autoload :Capture, 'msf/core/exploit/capture' +# FileFormat +require 'msf/core/exploit/fileformat' +require 'msf/core/exploit/pdf_parse' +require 'msf/core/exploit/pdf' +require 'msf/core/exploit/riff' - # FileFormat - autoload :FILEFORMAT, 'msf/core/exploit/fileformat' - autoload :PDF_Parse, 'msf/core/exploit/pdf_parse' - autoload :PDF, 'msf/core/exploit/pdf' - autoload :RIFF, 'msf/core/exploit/riff' +# Oracle +require 'msf/core/exploit/oracle' - # Oracle - autoload :ORACLE, 'msf/core/exploit/oracle' +# tekniqz +require 'msf/core/exploit/fmtstr' - # tekniqz - autoload :FormatString, 'msf/core/exploit/fmtstr' +# Java +require 'msf/core/exploit/java' - # Java - autoload :Java, 'msf/core/exploit/java' +# WBEM +require 'msf/core/exploit/wbemexec' - # WBEM - autoload :WbemExec, 'msf/core/exploit/wbemexec' -end diff --git a/lib/msf/core/exploit/mssql.rb b/lib/msf/core/exploit/mssql.rb index 92dac9fb64..1ed079b573 100644 --- a/lib/msf/core/exploit/mssql.rb +++ b/lib/msf/core/exploit/mssql.rb @@ -1,5 +1,9 @@ require 'msf/core' require 'msf/core/exploit/mssql_commands' +require 'rex/proto/ntlm/crypt' +require 'rex/proto/ntlm/constants' +require 'rex/proto/ntlm/utils' +require 'rex/proto/ntlm/exceptions' module Msf diff --git a/lib/msf/core/exploit/ntlm.rb b/lib/msf/core/exploit/ntlm.rb index c6e0d43941..f9bf06a401 100644 --- a/lib/msf/core/exploit/ntlm.rb +++ b/lib/msf/core/exploit/ntlm.rb @@ -1,3 +1,7 @@ +require 'rex/proto/ntlm/constants' +require 'rex/proto/ntlm/crypt' +require 'rex/proto/ntlm/base' +require 'rex/proto/ntlm/message' module Msf diff --git a/lib/msf/core/exploit/omelet.rb b/lib/msf/core/exploit/omelet.rb index fa82d35467..6d11e93f63 100644 --- a/lib/msf/core/exploit/omelet.rb +++ b/lib/msf/core/exploit/omelet.rb @@ -1,5 +1,6 @@ # $Id$ +require 'rex/exploitation/omelet' module Msf diff --git a/lib/msf/core/exploit/seh.rb b/lib/msf/core/exploit/seh.rb index d81b775888..7fb90b4008 100644 --- a/lib/msf/core/exploit/seh.rb +++ b/lib/msf/core/exploit/seh.rb @@ -1,3 +1,4 @@ +require 'rex/exploitation/seh' module Msf diff --git a/lib/msf/core/exploit/seh.rb.ut.rb b/lib/msf/core/exploit/seh.rb.ut.rb index 2387006ca5..ed99941fd5 100644 --- a/lib/msf/core/exploit/seh.rb.ut.rb +++ b/lib/msf/core/exploit/seh.rb.ut.rb @@ -3,6 +3,7 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..')) require 'test/unit' +require 'rex' require 'msf/core' require 'msf/core/exploit/seh' diff --git a/lib/msf/core/exploit/smb.rb b/lib/msf/core/exploit/smb.rb index e823af8309..e8ac242aa1 100644 --- a/lib/msf/core/exploit/smb.rb +++ b/lib/msf/core/exploit/smb.rb @@ -1,3 +1,7 @@ +require 'rex/proto/smb' +require 'rex/proto/ntlm' +require 'rex/proto/dcerpc' +require 'rex/encoder/ndr' module Msf diff --git a/lib/msf/core/exploit/smtp_deliver.rb b/lib/msf/core/exploit/smtp_deliver.rb index 49196e12c9..077af3078c 100644 --- a/lib/msf/core/exploit/smtp_deliver.rb +++ b/lib/msf/core/exploit/smtp_deliver.rb @@ -1,6 +1,7 @@ module Msf require 'msf/core/exploit/tcp' +require 'rex/mime' ### # diff --git a/lib/msf/core/exploit/sunrpc.rb b/lib/msf/core/exploit/sunrpc.rb index 5117bd993f..2ab3d1c103 100644 --- a/lib/msf/core/exploit/sunrpc.rb +++ b/lib/msf/core/exploit/sunrpc.rb @@ -1,3 +1,4 @@ +require 'rex/proto/sunrpc' module Msf diff --git a/lib/msf/core/exploit/tftp.rb b/lib/msf/core/exploit/tftp.rb index 540a116be2..300b2553af 100644 --- a/lib/msf/core/exploit/tftp.rb +++ b/lib/msf/core/exploit/tftp.rb @@ -2,6 +2,7 @@ # $Id$ ## +require 'rex/proto/tftp' module Msf diff --git a/lib/msf/core/exploit_driver.rb b/lib/msf/core/exploit_driver.rb index 084460828a..cffb462535 100644 --- a/lib/msf/core/exploit_driver.rb +++ b/lib/msf/core/exploit_driver.rb @@ -1,3 +1,4 @@ +require 'msf/core' module Msf @@ -224,7 +225,7 @@ protected # Wait the payload to acquire a session if this isn't a passive-style # exploit. - return if not delay + return if not if (force_wait_for_session == true) or (exploit.passive? == false and exploit.handler_enabled?) diff --git a/lib/msf/core/handler/passivex.rb b/lib/msf/core/handler/passivex.rb index c164cd85cd..54e5323c3d 100644 --- a/lib/msf/core/handler/passivex.rb +++ b/lib/msf/core/handler/passivex.rb @@ -1,3 +1,5 @@ +require 'rex/io/stream_abstraction' +require 'rex/sync/ref' module Msf module Handler diff --git a/lib/msf/core/handler/reverse_https.rb b/lib/msf/core/handler/reverse_https.rb index 26ac18df96..0d25fb9547 100644 --- a/lib/msf/core/handler/reverse_https.rb +++ b/lib/msf/core/handler/reverse_https.rb @@ -1,3 +1,5 @@ +require 'rex/io/stream_abstraction' +require 'rex/sync/ref' module Msf module Handler diff --git a/lib/msf/core/handler/reverse_tcp.rb b/lib/msf/core/handler/reverse_tcp.rb index af800a7bc7..e4d7792ccf 100644 --- a/lib/msf/core/handler/reverse_tcp.rb +++ b/lib/msf/core/handler/reverse_tcp.rb @@ -1,3 +1,4 @@ +require 'rex/socket' require 'thread' module Msf diff --git a/lib/msf/core/module.rb b/lib/msf/core/module.rb index 9aa6d76289..e1de1ac0c8 100644 --- a/lib/msf/core/module.rb +++ b/lib/msf/core/module.rb @@ -105,13 +105,12 @@ class Module true end - autoload :Author, 'msf/core/module/author' - autoload :Platform, 'msf/core/module/platform' - autoload :PlatformList, 'msf/core/module/platform_list' - autoload :Reference, 'msf/core/module/reference' - autoload :Target, 'msf/core/module/target' - autoload :HasActions, 'msf/core/module/has_actions' - autoload :AuxiliaryAction, 'msf/core/module/auxiliary_action' + require 'msf/core/module/author' + require 'msf/core/module/platform_list' + require 'msf/core/module/reference' + require 'msf/core/module/target' + require 'msf/core/module/auxiliary_action' + require 'msf/core/module/has_actions' # # Creates an instance of an abstract module using the supplied information diff --git a/lib/msf/core/option_container.rb b/lib/msf/core/option_container.rb index 4b895b14e7..742008dded 100644 --- a/lib/msf/core/option_container.rb +++ b/lib/msf/core/option_container.rb @@ -1,5 +1,6 @@ require 'resolv' require 'msf/core' +require 'rex/socket' module Msf diff --git a/lib/msf/core/payload.rb b/lib/msf/core/payload.rb index c60f9200bb..df48388c33 100644 --- a/lib/msf/core/payload.rb +++ b/lib/msf/core/payload.rb @@ -1,5 +1,5 @@ require 'msf/core' -autoload :Metasm, 'metasm' +require 'metasm' module Msf @@ -14,19 +14,19 @@ class Payload < Msf::Module require 'rex/payloads' - autoload :Single, 'msf/core/payload/single' - autoload :Generic, 'msf/core/payload/generic' - autoload :Stager, 'msf/core/payload/stager' + require 'msf/core/payload/single' + require 'msf/core/payload/generic' + require 'msf/core/payload/stager' # Platform specific includes - autoload :Aix, 'msf/core/payload/aix' - autoload :Bsd, 'msf/core/payload/bsd' - autoload :Linux, 'msf/core/payload/linux' - autoload :Osx, 'msf/core/payload/osx' - autoload :Solaris, 'msf/core/payload/solaris' - autoload :Windows, 'msf/core/payload/windows' - autoload :Netware, 'msf/core/payload/netware' - autoload :Java, 'msf/core/payload/java' + require 'msf/core/payload/aix' + require 'msf/core/payload/bsd' + require 'msf/core/payload/linux' + require 'msf/core/payload/osx' + require 'msf/core/payload/solaris' + require 'msf/core/payload/windows' + require 'msf/core/payload/netware' + require 'msf/core/payload/java' ## # diff --git a/lib/msf/core/payload/windows/reflectivedllinject.rb b/lib/msf/core/payload/windows/reflectivedllinject.rb index 03a15eba67..d5e7d11050 100644 --- a/lib/msf/core/payload/windows/reflectivedllinject.rb +++ b/lib/msf/core/payload/windows/reflectivedllinject.rb @@ -1,5 +1,6 @@ require 'msf/core' +require 'rex/peparsey' module Msf diff --git a/lib/msf/core/payload/windows/x64/reflectivedllinject.rb b/lib/msf/core/payload/windows/x64/reflectivedllinject.rb index f8086237c6..b6569a1be3 100644 --- a/lib/msf/core/payload/windows/x64/reflectivedllinject.rb +++ b/lib/msf/core/payload/windows/x64/reflectivedllinject.rb @@ -1,5 +1,6 @@ require 'msf/core' +require 'rex/peparsey' module Msf diff --git a/lib/msf/core/plugin.rb b/lib/msf/core/plugin.rb index 07dcd5f23b..ce221848a1 100644 --- a/lib/msf/core/plugin.rb +++ b/lib/msf/core/plugin.rb @@ -1,3 +1,4 @@ +require 'rex/sync/ref' module Msf diff --git a/lib/msf/core/rpc/client.rb b/lib/msf/core/rpc/client.rb index 4cf6e9b037..9617f3a5b1 100644 --- a/lib/msf/core/rpc/client.rb +++ b/lib/msf/core/rpc/client.rb @@ -1,4 +1,5 @@ require "xmlrpc/client" +require "rex" module Msf module RPC diff --git a/lib/msf/core/rpc/console.rb b/lib/msf/core/rpc/console.rb index b3ab4a1be3..cbcedcf897 100644 --- a/lib/msf/core/rpc/console.rb +++ b/lib/msf/core/rpc/console.rb @@ -1,4 +1,5 @@ require 'pp' +require 'rex' require 'msf/ui/web/driver' module Msf diff --git a/lib/msf/core/rpc/service.rb b/lib/msf/core/rpc/service.rb index 8031a6715d..01c1fb0aa5 100644 --- a/lib/msf/core/rpc/service.rb +++ b/lib/msf/core/rpc/service.rb @@ -1,4 +1,6 @@ require "xmlrpc/server" +require 'rex/service_manager' +require "rex" module Msf diff --git a/lib/msf/core/rpc/session.rb b/lib/msf/core/rpc/session.rb index c2ee2b676d..76a014b840 100644 --- a/lib/msf/core/rpc/session.rb +++ b/lib/msf/core/rpc/session.rb @@ -1,3 +1,5 @@ +require 'rex' +require 'rex/ui/text/output/buffer' module Msf module RPC diff --git a/lib/msf/core/session.rb b/lib/msf/core/session.rb index 6b9c3306c8..5533055c88 100644 --- a/lib/msf/core/session.rb +++ b/lib/msf/core/session.rb @@ -84,12 +84,15 @@ module Session end # Direct descendents - autoload :Interactive, 'msf/core/session/interactive' - autoload :Basic, 'msf/core/session/basic' - autoload :Comm, 'msf/core/session/comm' + require 'msf/core/session/interactive' + require 'msf/core/session/basic' + require 'msf/core/session/comm' # Provider interfaces - autoload :Provider, 'msf/core/session/provider' + require 'msf/core/session/provider/single_command_execution' + require 'msf/core/session/provider/multi_command_execution' + require 'msf/core/session/provider/single_command_shell' + require 'msf/core/session/provider/multi_command_shell' def self.type "unknown" diff --git a/lib/msf/core/session/comm.rb b/lib/msf/core/session/comm.rb index 1e96181c29..1b7c96d593 100644 --- a/lib/msf/core/session/comm.rb +++ b/lib/msf/core/session/comm.rb @@ -1,3 +1,4 @@ +require 'rex/socket' module Msf module Session diff --git a/lib/msf/core/session/interactive.rb b/lib/msf/core/session/interactive.rb index 3ff06564f9..b808f2fbdd 100644 --- a/lib/msf/core/session/interactive.rb +++ b/lib/msf/core/session/interactive.rb @@ -1,3 +1,5 @@ +require 'rex/ui' +require 'rex/io/ring_buffer' module Msf module Session diff --git a/lib/msf/core/session/provider.rb b/lib/msf/core/session/provider.rb deleted file mode 100644 index dbe8f9ce75..0000000000 --- a/lib/msf/core/session/provider.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Msf -module Session -module Provider - autoload :SingleCommandExecution, 'msf/core/session/provider/single_command_execution' - autoload :MultiCommandExecution, 'msf/core/session/provider/multi_command_execution' - autoload :SingleCommandShell, 'msf/core/session/provider/single_command_shell' - autoload :MultiCommandShell, 'msf/core/session/provider/multi_command_shell' -end -end -end diff --git a/lib/msf/ui.rb b/lib/msf/ui.rb index 555f6b7d09..09e77933f0 100644 --- a/lib/msf/ui.rb +++ b/lib/msf/ui.rb @@ -1,8 +1,10 @@ module Msf module Ui - autoload :Banner, 'msf/ui/banner' - autoload :Driver, 'msf/ui/driver' - autoload :Common, 'msf/ui/common' - autoload :Console, 'msf/ui/console' end end + +require 'rex/ui' +require 'msf/ui/banner' +require 'msf/ui/driver' +require 'msf/ui/common' +require 'msf/ui/console' diff --git a/lib/msf/ui/console/command_dispatcher/db.rb b/lib/msf/ui/console/command_dispatcher/db.rb index dd3b6339c4..87f1ca5f39 100644 --- a/lib/msf/ui/console/command_dispatcher/db.rb +++ b/lib/msf/ui/console/command_dispatcher/db.rb @@ -1,4 +1,6 @@ +require 'rexml/document' +require 'rex/parser/nmap_xml' require 'msf/core/db_export' module Msf @@ -1274,8 +1276,6 @@ class Db warnings = 0 framework.db.import_file(:filename => filename) do |type,data| case type - when :debug - print_status("DEBUG: #{data.inspect}") when :filetype print_status("Importing '#{data}' data") when :address diff --git a/lib/msf/ui/console/command_dispatcher/nop.rb b/lib/msf/ui/console/command_dispatcher/nop.rb index 9ea6586431..aa54d1ae7e 100644 --- a/lib/msf/ui/console/command_dispatcher/nop.rb +++ b/lib/msf/ui/console/command_dispatcher/nop.rb @@ -1,3 +1,4 @@ +require 'rex/parser/arguments' module Msf module Ui diff --git a/lib/msf/ui/console/command_dispatcher/payload.rb b/lib/msf/ui/console/command_dispatcher/payload.rb index bd3d46abd9..2c519ff6ea 100644 --- a/lib/msf/ui/console/command_dispatcher/payload.rb +++ b/lib/msf/ui/console/command_dispatcher/payload.rb @@ -2,6 +2,7 @@ # $Id$ ## +require 'rex/parser/arguments' module Msf module Ui diff --git a/lib/msf/ui/web/driver.rb b/lib/msf/ui/web/driver.rb index 042f6a53d9..4b1cbf456b 100644 --- a/lib/msf/ui/web/driver.rb +++ b/lib/msf/ui/web/driver.rb @@ -1,3 +1,4 @@ +require 'rex/proto/http' require 'msf/core' require 'msf/base' require 'msf/ui' @@ -6,6 +7,7 @@ module Msf module Ui module Web +require 'rex/io/bidirectional_pipe' require 'msf/ui/web/console' diff --git a/lib/msf/util.rb b/lib/msf/util.rb index e4b43787be..1bd15f77b5 100644 --- a/lib/msf/util.rb +++ b/lib/msf/util.rb @@ -10,15 +10,16 @@ require 'msf/core' +require 'rex' module Msf module Util - # Executable generation and encoding - autoload :EXE, 'msf/util/exe' - - # Parse SVN entries - autoload :SVN, 'msf/util/svn' - end end + +# Executable generation and encoding +require 'msf/util/exe' + +# Parse SVN entries +require 'msf/util/svn' diff --git a/lib/msf/util/exe.rb b/lib/msf/util/exe.rb index 70f47573b6..c3431600db 100644 --- a/lib/msf/util/exe.rb +++ b/lib/msf/util/exe.rb @@ -13,15 +13,17 @@ # ### -require 'rex' - -autoload :Metasm, 'metasm' -require 'digest/sha1' - module Msf module Util class EXE +require 'rex' +require 'rex/peparsey' +require 'rex/pescan' +require 'rex/zip' +require 'metasm' +require 'digest/sha1' + ## # # Helper functions common to multiple generators @@ -558,70 +560,28 @@ class EXE return mo end - # - # Create a 32-bit Linux ELF containing the payload provided in +code+ - # - # For the default template, this method just appends the payload. For - # user-provided templates, modifies the header to mark all executable - # segments as writable and overwrites the entrypoint (usually _start) with - # the payload. - # def self.to_linux_x86_elf(framework, code, opts={}) - unless opts[:template] - default = true - end # Allow the user to specify their own template set_template_default(opts, "template_x86_linux.bin") + elf = '' + File.open(opts[:template], "rb") { |fd| + elf = fd.read(fd.stat.size) + } + # The old way to do it is like other formats, just overwrite a big # block of rwx mem with our shellcode. #bo = elf.index( "\x90\x90\x90\x90" * 1024 ) #co = elf.index( " " * 512 ) #elf[bo, 2048] = [code].pack('a2048') if bo - if default - # The new template is just an ELF header with its entry point set to - # the end of the file, so just append shellcode to it and fixup - # p_filesz and p_memsz in the header for a working ELF executable. - elf = '' - File.open(opts[:template], "rb") { |fd| - elf = fd.read(fd.stat.size) - } - - elf << code - elf[0x44,4] = [elf.length + code.length].pack('V') - elf[0x48,4] = [elf.length + code.length].pack('V') - else - # If this isn't our normal template, we have to do some fancy - # header patching to mark the .text section rwx before putting our - # payload into the entry point. - - # read in the template and parse it - e = Metasm::ELF.decode_file(opts[:template]) - - # This will become a modified copy of the template's original phdr - new_phdr = Metasm::EncodedData.new - e.segments.each { |s| - # Be lazy and mark any executable segment as writable. Doing - # it this way means we don't have to care about which one - # contains .text - if s.flags.include? "X" - s.flags += [ "W" ] - end - new_phdr << s.encode(e) - } - - # Copy the original file - elf = File.read(opts[:template]) - - # Replace the header with our rwx modified version - elf[e.header.phoff, new_phdr.data.length] = new_phdr.data - - # Replace code at the entrypoint with our payload - entry_off = e.addr_to_off(e.label_addr('entrypoint')) - elf[entry_off, code.length] = code - end + # The new template is just an ELF header with its entry point set to + # the end of the file, so just append shellcode to it and fixup + # p_filesz and p_memsz in the header for a working ELF executable. + elf << code + elf[0x44,4] = [elf.length + code.length].pack('V') + elf[0x48,4] = [elf.length + code.length].pack('V') return elf end diff --git a/lib/rex.rb b/lib/rex.rb index b64ddc87c6..97a848e7d9 100644 --- a/lib/rex.rb +++ b/lib/rex.rb @@ -40,77 +40,53 @@ end # Generic classes require 'rex/constants' require 'rex/exceptions' +require 'rex/transformer' +require 'rex/text' +require 'rex/time' +require 'rex/job_container' +require 'rex/file' -module Rex - # Generic modules - autoload :FileUtils, 'rex/file' - autoload :Find, 'rex/file' - autoload :Quickfile, 'rex/file' - autoload :Text, 'rex/text' - autoload :Job, 'rex/job_container' - autoload :JobContainer, 'rex/job_container' - autoload :Transformer, 'rex/transformer' - autoload :ExtTime, 'rex/time' - autoload :Zip, 'rex/zip' +# Thread safety and synchronization +require 'rex/sync' - # Thread safety and synchronization - autoload :ReadWriteLock, 'rex/sync/read_write_lock' - autoload :ThreadSafe, 'rex/sync/thread_safe' - autoload :Ref, 'rex/sync/ref' - autoload :Sync, 'rex/sync/event' +# Thread factory +require 'rex/thread_factory' - # Thread factory - autoload :ThreadFactory, 'rex/thread_factory' +# Encoding +require 'rex/encoder/xor' +require 'rex/encoding/xor' - # Encoding - autoload :Encoder, 'rex/encoder' - autoload :Encoders, 'rex/encoders' - autoload :Encoding, 'rex/encoding' +# Architecture subsystem +require 'rex/arch' - # Architecture subsystem - autoload :Arch, 'rex/arch' +# Assembly +require 'rex/assembly/nasm' - # Assembly - autoload :Assembly, 'rex/assembly/nasm' +# Logging +require 'rex/logging/log_dispatcher' - # Logging - autoload :Logging, 'rex/logging' +# IO +require 'rex/io/stream' +require 'rex/io/stream_abstraction' +require 'rex/io/stream_server' - # IO - autoload :IO, 'rex/io' +# Sockets +require 'rex/socket' - # Sockets - autoload :Socket, 'rex/socket' +# Protocols - # Platforms - autoload :Platforms, 'rex/platforms' +require 'rex/proto' - # Protocols - autoload :Proto, 'rex/proto' +# Parsers +require 'rex/parser/arguments' +require 'rex/parser/ini' - # Service handling - autoload :Service, 'rex/service' - autoload :ServiceManager, 'rex/service_manager' - # Parsers - autoload :Parser, 'rex/parser' +# Compatibility +require 'rex/compat' - # Compatibility - autoload :Compat, 'rex/compat' - - # User interface - autoload :Ui, 'rex/ui' - - # Meterpreter - autoload :Post, 'rex/post' - autoload :Script, 'rex/script' - - # PE Parsing - autoload :PeParsey, 'rex/peparsey' - - # Exploit techniques - autoload :Exploitation, 'rex/exploitation' -end +# Platforms +require 'rex/platforms' # Overload the Kernel.sleep() function to be thread-safe diff --git a/lib/rex/arch.rb b/lib/rex/arch.rb index 53db55b72b..5863f8ae78 100644 --- a/lib/rex/arch.rb +++ b/lib/rex/arch.rb @@ -2,6 +2,7 @@ require 'rex/constants' module Rex + ### # # This module provides generalized methods for performing operations that are @@ -14,8 +15,8 @@ module Arch # # Architecture classes # - autoload :X86, 'rex/arch/x86' - autoload :Sparc, 'rex/arch/sparc' + require 'rex/arch/x86' + require 'rex/arch/sparc' # # This routine adjusts the stack pointer for a given architecture. diff --git a/lib/rex/encoder.rb b/lib/rex/encoder.rb deleted file mode 100644 index 536d382c0d..0000000000 --- a/lib/rex/encoder.rb +++ /dev/null @@ -1,17 +0,0 @@ -## -# $Id$ -# -# This file maps encoders for autoload -## - -module Rex::Encoder - # Encoder support code - autoload :Xor, 'rex/encoder/xor' - autoload :Alpha2, 'rex/encoder/alpha2' - autoload :NonAlpha, 'rex/encoder/nonalpha' - autoload :NonUpper, 'rex/encoder/nonupper' - - # Hrm? Is these in the wrong module? - autoload :XDR, 'rex/encoder/xdr' - autoload :NDR, 'rex/encoder/ndr' -end diff --git a/lib/rex/encoder/alpha2.rb b/lib/rex/encoder/alpha2.rb index f1b013844d..b3983f62b7 100644 --- a/lib/rex/encoder/alpha2.rb +++ b/lib/rex/encoder/alpha2.rb @@ -18,16 +18,14 @@ module Rex module Encoder module Alpha2 +end end end - # - # autoload the Alpha2 encoders - # - autoload :Generic, 'rex/encoder/alpha2/generic' - autoload :AlphaMixed, 'rex/encoder/alpha2/alpha_mixed' - autoload :AlphaUpper, 'rex/encoder/alpha2/alpha_upper' - autoload :UnicodeMixed, 'rex/encoder/alpha2/unicode_mixed' - autoload :UnicodeUpper, 'rex/encoder/alpha2/unicode_upper' +# +# include the Alpha2 encodings +# -end -end -end +require 'rex/encoder/alpha2/generic' +require 'rex/encoder/alpha2/alpha_mixed' +require 'rex/encoder/alpha2/alpha_upper' +require 'rex/encoder/alpha2/unicode_mixed' +require 'rex/encoder/alpha2/unicode_upper' \ No newline at end of file diff --git a/lib/rex/encoder/xor.rb b/lib/rex/encoder/xor.rb index 599a712aa4..5474e92465 100644 --- a/lib/rex/encoder/xor.rb +++ b/lib/rex/encoder/xor.rb @@ -10,9 +10,6 @@ module Encoder ### class Xor - autoload :Dword, 'rex/encoder/xor/dword' - autoload :DwordAdditive, 'rex/encoder/xor/dword_additive' - attr_accessor :raw, :encoded, :badchars, :opts, :key, :fkey # :nodoc: # @@ -68,5 +65,5 @@ class Xor end -end -end +end end + diff --git a/lib/rex/encoders.rb b/lib/rex/encoders.rb deleted file mode 100644 index 5a4ed855c1..0000000000 --- a/lib/rex/encoders.rb +++ /dev/null @@ -1,11 +0,0 @@ -## -# $Id$ -# -# This file maps encoders for autoload -## -require 'rex' - -module Rex::Encoders - autoload :XorDword, 'rex/encoders/xor_dword' - autoload :XorDwordAdditive, 'rex/encoders/xor_dword_additive' -end diff --git a/lib/rex/encoding.rb b/lib/rex/encoding.rb deleted file mode 100644 index 60a8c24302..0000000000 --- a/lib/rex/encoding.rb +++ /dev/null @@ -1,10 +0,0 @@ -## -# $Id$ -# -# This file maps encodings for autoload -## - -module Rex::Encoding - # Encoding support code - autoload :Xor, 'rex/encoding/xor' -end diff --git a/lib/rex/encoding/xor.rb b/lib/rex/encoding/xor.rb index 513d1f8546..1c0e3c3e7c 100644 --- a/lib/rex/encoding/xor.rb +++ b/lib/rex/encoding/xor.rb @@ -1,19 +1,20 @@ +#!/usr/bin/env ruby + +# +# make sure the namespace is created +# + module Rex module Encoding module Xor +end end end - # - # autoload the Xor encodings - # - autoload :Generic, 'rex/encoding/xor/generic' - autoload :Byte, 'rex/encoding/xor/byte' - autoload :Word, 'rex/encoding/xor/word' - autoload :Dword, 'rex/encoding/xor/dword' - autoload :DwordAdditive, 'rex/encoding/xor/dword_additive' - autoload :Qword, 'rex/encoding/xor/qword' +# +# include the Xor encodings +# - autoload :Exception, 'rex/encoding/xor/exceptions' - -end -end -end +require 'rex/encoding/xor/generic' +require 'rex/encoding/xor/byte' +require 'rex/encoding/xor/word' +require 'rex/encoding/xor/dword' +require 'rex/encoding/xor/qword' \ No newline at end of file diff --git a/lib/rex/exploitation.rb b/lib/rex/exploitation.rb deleted file mode 100644 index 286d3e516b..0000000000 --- a/lib/rex/exploitation.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Rex -module Exploitation - autoload :Seh, 'rex/exploitation/seh' - autoload :OpcodeDb, 'rex/exploitation/opcodedb' - - # CMD stagers - autoload :CmdStagerBase, 'rex/exploitation/cmdstager/base' - autoload :CmdStagerDebugAsm, 'rex/exploitation/cmdstager/debug_asm' - autoload :CmdStagerDebugWrite, 'rex/exploitation/cmdstager/debug_write' - autoload :CmdStagerTFTP, 'rex/exploitation/cmdstager/tftp' - autoload :CmdStagerVBS, 'rex/exploitation/cmdstager/vbs' - - # Shellcode slicing - autoload :Egghunter, 'rex/exploitation/egghunter' - autoload :Omelet, 'rex/exploitation/omelet' - - # Javascript fun - autoload :EncryptJS, 'rex/exploitation/encryptjs' - autoload :HeapLib, 'rex/exploitation/heaplib' - autoload :ObfuscateJS, 'rex/exploitation/obfuscatejs' - autoload :JavascriptOSDetect, 'rex/exploitation/javascriptosdetect' -end -end diff --git a/lib/rex/exploitation/cmdstager/base.rb b/lib/rex/exploitation/cmdstager/base.rb index 71b5c60b49..fa6eab8fd7 100644 --- a/lib/rex/exploitation/cmdstager/base.rb +++ b/lib/rex/exploitation/cmdstager/base.rb @@ -1,6 +1,6 @@ -## -# $Id$ -## +require 'rex/text' +require 'rex/arch' +require 'msf/core/framework' module Rex module Exploitation diff --git a/lib/rex/exploitation/cmdstager/debug_asm.rb b/lib/rex/exploitation/cmdstager/debug_asm.rb index 9cf8353d6d..25f43d8553 100644 --- a/lib/rex/exploitation/cmdstager/debug_asm.rb +++ b/lib/rex/exploitation/cmdstager/debug_asm.rb @@ -1,7 +1,11 @@ ## -# $Id$ +# $Id: debug_asm.rb 12595 2011-05-12 18:33:49Z jduck $ ## +require 'rex/text' +require 'rex/arch' +require 'msf/core/framework' + module Rex module Exploitation diff --git a/lib/rex/exploitation/cmdstager/debug_write.rb b/lib/rex/exploitation/cmdstager/debug_write.rb index a5f353fd0a..5b32edfe7c 100644 --- a/lib/rex/exploitation/cmdstager/debug_write.rb +++ b/lib/rex/exploitation/cmdstager/debug_write.rb @@ -1,7 +1,11 @@ ## -# $Id$ +# $Id: debug_write.rb 12595 2011-05-12 18:33:49Z jduck $ ## +require 'rex/text' +require 'rex/arch' +require 'msf/core/framework' + module Rex module Exploitation diff --git a/lib/rex/exploitation/cmdstager/tftp.rb b/lib/rex/exploitation/cmdstager/tftp.rb index 7b26d73be4..d389d95e61 100644 --- a/lib/rex/exploitation/cmdstager/tftp.rb +++ b/lib/rex/exploitation/cmdstager/tftp.rb @@ -2,6 +2,10 @@ # $Id$ ## +require 'rex/text' +require 'rex/arch' +require 'msf/core/framework' + module Rex module Exploitation diff --git a/lib/rex/exploitation/cmdstager/vbs.rb b/lib/rex/exploitation/cmdstager/vbs.rb index d033adf963..47d74cadc6 100644 --- a/lib/rex/exploitation/cmdstager/vbs.rb +++ b/lib/rex/exploitation/cmdstager/vbs.rb @@ -1,7 +1,11 @@ ## -# $Id$ +# $Id: vbs.rb 12595 2011-05-12 18:33:49Z jduck $ ## +require 'rex/text' +require 'rex/arch' +require 'msf/core/framework' + module Rex module Exploitation diff --git a/lib/rex/exploitation/omelet.rb b/lib/rex/exploitation/omelet.rb index 1c7569d75e..6147949f73 100644 --- a/lib/rex/exploitation/omelet.rb +++ b/lib/rex/exploitation/omelet.rb @@ -103,8 +103,12 @@ class Omelet nr_eggs_hex = "%02x" % nr_eggs eggsize_hex = "%02x" % eggsize - hextag = eggtag.unpack('C*').map { |b| "%02x" % b }.join - hextag << "01" + hextag = '' + eggtag.each_byte do |thischar| + decchar = "%02x" % thischar + hextag = decchar + hextag + end + hextag = hextag + "01" # search forward or backward ? setflag = nil diff --git a/lib/rex/io.rb b/lib/rex/io.rb deleted file mode 100644 index 1390ad3d9e..0000000000 --- a/lib/rex/io.rb +++ /dev/null @@ -1,16 +0,0 @@ -## -# $Id$ -# -# This file simply provides an autoload interface for the children -# of Rex::IO -# -## -module Rex::IO - autoload :Stream, 'rex/io/stream' - autoload :StreamAbstraction, 'rex/io/stream_abstraction' - autoload :StreamServer, 'rex/io/stream_server' - - autoload :BidirectionalPipe, 'rex/io/bidirectional_pipe' - autoload :DatagramAbstraction, 'rex/io/datagram_abstraction' - autoload :RingBuffer, 'rex/io/ring_buffer' -end diff --git a/lib/rex/logging.rb b/lib/rex/logging.rb index d002cc2c95..f8743e55f8 100644 --- a/lib/rex/logging.rb +++ b/lib/rex/logging.rb @@ -1,17 +1,4 @@ -## -# $Id: $ -# -# maps autoload for logging classes -## +#!/usr/bin/env ruby require 'rex/constants' # for LEV_'s - -module Rex -module Logging - autoload :LogSink, 'rex/logging/log_sink' - autoload :Sinks, 'rex/logging/sinks' -end -end - -# This defines a global so it must be loaded always -require 'rex/logging/log_dispatcher' +require 'rex/logging/log_dispatcher' \ No newline at end of file diff --git a/lib/rex/logging/log_dispatcher.rb b/lib/rex/logging/log_dispatcher.rb index b9a7698b9d..81e21a541a 100644 --- a/lib/rex/logging/log_dispatcher.rb +++ b/lib/rex/logging/log_dispatcher.rb @@ -1,4 +1,5 @@ require 'rex/sync' +require 'rex/logging/log_sink' module Rex module Logging diff --git a/lib/rex/logging/log_sink.rb b/lib/rex/logging/log_sink.rb index 36f41bc294..6726c3c01b 100644 --- a/lib/rex/logging/log_sink.rb +++ b/lib/rex/logging/log_sink.rb @@ -37,3 +37,6 @@ end end end + +require 'rex/logging/sinks/flatfile' +require 'rex/logging/sinks/stderr' \ No newline at end of file diff --git a/lib/rex/logging/sinks.rb b/lib/rex/logging/sinks.rb deleted file mode 100644 index d83fa4bc01..0000000000 --- a/lib/rex/logging/sinks.rb +++ /dev/null @@ -1,16 +0,0 @@ -## -# $Id$ -# -# Map log sinks for autload -## - -module Rex -module Logging -module Sinks - - autoload :Flatfile, 'rex/logging/sinks/flatfile' - autoload :Stderr, 'rex/logging/sinks/stderr' - -end -end -end diff --git a/lib/rex/logging/sinks/flatfile.rb b/lib/rex/logging/sinks/flatfile.rb index 0a1386072b..bbe5248a95 100644 --- a/lib/rex/logging/sinks/flatfile.rb +++ b/lib/rex/logging/sinks/flatfile.rb @@ -1,5 +1,3 @@ -require 'rex/logging' - module Rex module Logging module Sinks diff --git a/lib/rex/parser.rb b/lib/rex/parser.rb deleted file mode 100644 index 895ce029e8..0000000000 --- a/lib/rex/parser.rb +++ /dev/null @@ -1,23 +0,0 @@ -## -# $Id$ -# -# This file maps parsers for autoload -## - -module Rex -module Parser - # General parsers - autoload :Arguments, 'rex/parser/arguments' - autoload :Ini, 'rex/parser/ini' - - # Data import parsers - autoload :NmapXMLStreamParser, 'rex/parser/nmap_xml' - autoload :NexposeXMLStreamParser, 'rex/parser/nexpose_xml' - autoload :RetinaXMLStreamParser, 'rex/parser/retina_xml' - autoload :NetSparkerXMLStreamParser, 'rex/parser/netsparker_xml' - autoload :NessusXMLStreamParser, 'rex/parser/nessus_xml' - autoload :IP360XMLStreamParser, 'rex/parser/ip360_xml' - autoload :IP360ASPLXMLStreamParser, 'rex/parser/ip360_aspl_xml' - autoload :AppleBackupManifestDB, 'rex/parser/apple_backup_manifestdb' -end -end diff --git a/lib/rex/parser/nmap_xml.rb b/lib/rex/parser/nmap_xml.rb index 6d7e329e92..007a8ef7c6 100644 --- a/lib/rex/parser/nmap_xml.rb +++ b/lib/rex/parser/nmap_xml.rb @@ -59,8 +59,7 @@ class NmapXMLStreamParser end def reset_state - @host = { "status" => nil, "addrs" => {}, "ports" => [], "scripts" => {} } - @state = nil + @host = { "status" => nil, "addrs" => {}, "ports" => [] } end def tag_start(name, attributes) @@ -99,7 +98,6 @@ class NmapXMLStreamParser @host["status_reason"] = attributes["reason"] when "port" @host["ports"].push(attributes) - @state = :in_port_tag when "state" # refers to the state of a port; values are "open", "closed", or "filtered" @host["ports"].last["state"] = attributes["state"] @@ -108,21 +106,8 @@ class NmapXMLStreamParser # be any collisions on attribute names here, so just merge them. @host["ports"].last.merge!(attributes) when "script" - # Associate scripts under a port tag with the appropriate port. - # Other scripts from tags can only be associated with - # the host and scripts from tags don't really belong - # to anything, so ignore them - if @state == :in_port_tag - @host["ports"].last["scripts"] ||= {} - @host["ports"].last["scripts"][attributes["id"]] = attributes["output"] - elsif @host - @host["scripts"] ||= {} - @host["scripts"][attributes["id"]] = attributes["output"] - else - # post scripts are used for things like comparing all the found - # ssh keys to see if multiple hosts have the same key - # fingerprint. Ignore them. - end + @host["ports"].last["scripts"] ||= {} + @host["ports"].last["scripts"][attributes["id"]] = attributes["output"] when "trace" @host["trace"] = {"port" => attributes["port"], "proto" => attributes["proto"], "hops" => [] } when "hop" @@ -134,8 +119,6 @@ class NmapXMLStreamParser def tag_end(name) case name - when "port" - @state = nil when "host" on_found_host.call(@host) if on_found_host reset_state diff --git a/lib/rex/payloads.rb b/lib/rex/payloads.rb index a9490ec8e1..812e37951c 100644 --- a/lib/rex/payloads.rb +++ b/lib/rex/payloads.rb @@ -1,3 +1 @@ -module Rex::Payloads - autoload :Win32, 'rex/payloads/win32' -end +require 'rex/payloads/win32' \ No newline at end of file diff --git a/lib/rex/payloads/win32.rb b/lib/rex/payloads/win32.rb index f149e5f8e5..1ad36583b2 100644 --- a/lib/rex/payloads/win32.rb +++ b/lib/rex/payloads/win32.rb @@ -1,4 +1,2 @@ -module Rex::Payloads::Win32 - autoload :Common, 'rex/payloads/win32/common' - autoload :Kernel, 'rex/payloads/win32/kernel' -end +require 'rex/payloads/win32/common' +require 'rex/payloads/win32/kernel' \ No newline at end of file diff --git a/lib/rex/payloads/win32/kernel.rb b/lib/rex/payloads/win32/kernel.rb index defc87a9a5..92f961cc37 100644 --- a/lib/rex/payloads/win32/kernel.rb +++ b/lib/rex/payloads/win32/kernel.rb @@ -1,12 +1,13 @@ module Rex module Payloads module Win32 -module Kernel - autoload :Common, 'rex/payloads/win32/kernel/common' - autoload :Recovery, 'rex/payloads/win32/kernel/recovery' - autoload :Stager, 'rex/payloads/win32/kernel/stager' - autoload :Migration, 'rex/payloads/win32/kernel/migration' +require 'rex/payloads/win32/kernel/common' +require 'rex/payloads/win32/kernel/recovery' +require 'rex/payloads/win32/kernel/stager' +require 'rex/payloads/win32/kernel/migration' + +module Kernel # # Constructs a kernel-mode payload using the supplied options. The options diff --git a/lib/rex/peparsey.rb b/lib/rex/peparsey.rb index 71664f76e8..1a58ff8f99 100644 --- a/lib/rex/peparsey.rb +++ b/lib/rex/peparsey.rb @@ -1,11 +1,12 @@ #!/usr/bin/env ruby -# + # $Id$ -# module Rex module PeParsey - autoload :Pe, 'rex/peparsey/pe' - autoload :PeMemDump, 'rex/peparsey/pe_memdump' + end end + +require 'rex/peparsey/pe' +require 'rex/peparsey/pe_memdump' \ No newline at end of file diff --git a/lib/rex/pescan.rb b/lib/rex/pescan.rb index cdc625f2f9..e143cbb6a6 100644 --- a/lib/rex/pescan.rb +++ b/lib/rex/pescan.rb @@ -1,12 +1,13 @@ #!/usr/bin/env ruby -# + # $Id$ -# module Rex module PeScan - autoload :Analyze, 'rex/pescan/analyze' - autoload :Scanner, 'rex/pescan/scanner' - autoload :Search, 'rex/pescan/search' + end end + +require 'rex/pescan/analyze' +require 'rex/pescan/scanner' +require 'rex/pescan/search' \ No newline at end of file diff --git a/lib/rex/platforms.rb b/lib/rex/platforms.rb index 4c068be50a..1da07e02cd 100644 --- a/lib/rex/platforms.rb +++ b/lib/rex/platforms.rb @@ -1,11 +1 @@ -## -# $Id: $ -# -# This file maps Platforms for autoload -## - -module Rex -module Platforms - autoload :Windows, 'rex/platforms/windows' -end -end +require 'rex/platforms/windows' \ No newline at end of file diff --git a/lib/rex/post.rb b/lib/rex/post.rb index 5af4503f41..b9fb5579de 100644 --- a/lib/rex/post.rb +++ b/lib/rex/post.rb @@ -1,14 +1,8 @@ #!/usr/bin/env ruby # General independent containers -require 'rex/post/dir' -require 'rex/post/file' -require 'rex/post/file_stat' -require 'rex/post/io' require 'rex/post/permission' -require 'rex/post/process' -require 'rex/post/thread' # Post-exploitation clients -require 'rex/post/meterpreter' - +require 'rex/post/dispatch_ninja' +require 'rex/post/meterpreter' \ No newline at end of file diff --git a/lib/rex/post/gen.pl b/lib/rex/post/gen.pl new file mode 100644 index 0000000000..42a56d9a7d --- /dev/null +++ b/lib/rex/post/gen.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl +use strict; + + +foreach my $f ('atime', 'blockdev?', 'chardev?', 'ctime', 'directory?', + 'executable?', 'executable_real?', 'file?', 'ftype', 'grpowned?', + 'mtime', 'owned?', 'pipe?', 'readable?', 'readable_real?', 'setuid?', + 'setgid?', 'size', 'socket?', 'sticky?', 'symlink?', 'writeable?', + 'writeable_real?', 'zero?') { + + my $t = "\t"; + print "${t}def File.$f(name)\n\t${t}stat(name).$f\n${t}end\n"; +} diff --git a/lib/rex/proto.rb b/lib/rex/proto.rb index 3b60b91edb..c5f1b773d1 100644 --- a/lib/rex/proto.rb +++ b/lib/rex/proto.rb @@ -1,24 +1,13 @@ -## -# $Id$ -# -# This file maps Proto items for autoload -## +require 'rex/proto/http' +require 'rex/proto/smb' +require 'rex/proto/ntlm' +require 'rex/proto/dcerpc' +require 'rex/proto/drda' module Rex module Proto - autoload :Http, 'rex/proto/http' - autoload :SMB, 'rex/proto/smb' - autoload :NTLM, 'rex/proto/ntlm' - autoload :DCERPC, 'rex/proto/dcerpc' - autoload :DRDA, 'rex/proto/drda' - - autoload :SunRPC, 'rex/proto/sunrpc' - autoload :DHCP, 'rex/proto/dhcp' - autoload :TFTP, 'rex/proto/tftp' - autoload :RFB, 'rex/proto/rfb' - - attr_accessor :alias +attr_accessor :alias end end diff --git a/lib/rex/proto/dcerpc.rb b/lib/rex/proto/dcerpc.rb index d477558f3e..2c9f38759b 100644 --- a/lib/rex/proto/dcerpc.rb +++ b/lib/rex/proto/dcerpc.rb @@ -1,15 +1,6 @@ -module Rex -module Proto -module DCERPC - - autoload :Exceptions, 'rex/proto/dcerpc/exceptions' - autoload :UUID, 'rex/proto/dcerpc/uuid' - autoload :Response, 'rex/proto/dcerpc/response' - autoload :Client, 'rex/proto/dcerpc/client' - autoload :Packet, 'rex/proto/dcerpc/packet' - autoload :Handle, 'rex/proto/dcerpc/handle' - autoload :NDR, 'rex/proto/dcerpc/ndr' - -end -end -end +require 'rex/proto/dcerpc/uuid' +require 'rex/proto/dcerpc/response' +require 'rex/proto/dcerpc/client' +require 'rex/proto/dcerpc/packet' +require 'rex/proto/dcerpc/handle' +require 'rex/proto/dcerpc/ndr' \ No newline at end of file diff --git a/lib/rex/proto/drda.rb b/lib/rex/proto/drda.rb index 9950ca43b7..1e66b787aa 100644 --- a/lib/rex/proto/drda.rb +++ b/lib/rex/proto/drda.rb @@ -1,10 +1,5 @@ -module Rex -module Proto -module DRDA - autoload :Constants, 'rex/proto/drda/constants' - autoload :Utils, 'rex/proto/drda/utils' -end -end -end - +require 'rex/proto/drda/constants' require 'rex/proto/drda/packet' +require 'rex/proto/drda/utils' + + diff --git a/lib/rex/proto/http.rb b/lib/rex/proto/http.rb index 41ffe63f98..470c4b176a 100644 --- a/lib/rex/proto/http.rb +++ b/lib/rex/proto/http.rb @@ -1,18 +1,5 @@ -# These are required by all uses of Rex::Proto::Http require 'rex/proto/http/packet' require 'rex/proto/http/request' require 'rex/proto/http/response' - -# These are specific to use case -module Rex -module Proto -module Http - - autoload :Client, 'rex/proto/http/client' - - autoload :Server, 'rex/proto/http/server' - autoload :Handler, 'rex/proto/http/handler' - -end -end -end +require 'rex/proto/http/client' +require 'rex/proto/http/server' \ No newline at end of file diff --git a/lib/rex/proto/http/packet.rb b/lib/rex/proto/http/packet.rb index a031edb2c5..5030f3779c 100644 --- a/lib/rex/proto/http/packet.rb +++ b/lib/rex/proto/http/packet.rb @@ -1,5 +1,4 @@ require 'rex/proto/http' -require 'rex/text' module Rex module Proto diff --git a/lib/rex/proto/ntlm.rb b/lib/rex/proto/ntlm.rb index 0c6c204f5e..ff416f3733 100644 --- a/lib/rex/proto/ntlm.rb +++ b/lib/rex/proto/ntlm.rb @@ -1,13 +1,7 @@ -module Rex -module Proto -module NTLM - autoload :Constants, 'rex/proto/ntlm/constants' - autoload :Exceptions, 'rex/proto/ntlm/exceptions' +require 'rex/proto/ntlm/constants' +require 'rex/proto/ntlm/exceptions' +require 'rex/proto/ntlm/crypt' +require 'rex/proto/ntlm/utils' +require 'rex/proto/ntlm/base' +require 'rex/proto/ntlm/message' - autoload :Base, 'rex/proto/ntlm/base' - autoload :Crypt, 'rex/proto/ntlm/crypt' - autoload :Message, 'rex/proto/ntlm/message' - autoload :Utils, 'rex/proto/ntlm/utils' -end -end -end diff --git a/lib/rex/proto/ntlm/message.rb b/lib/rex/proto/ntlm/message.rb index 03ec7f5329..a00d85cbd6 100644 --- a/lib/rex/proto/ntlm/message.rb +++ b/lib/rex/proto/ntlm/message.rb @@ -45,8 +45,6 @@ #this module defines the message class , useful for easily handling type 1/2/3 ntlm messages -require 'rex/text' - require 'rex/proto/ntlm/base' require 'rex/proto/ntlm/constants' require 'rex/proto/ntlm/crypt' diff --git a/lib/rex/proto/smb.rb b/lib/rex/proto/smb.rb index 7786ae1756..2787024d56 100644 --- a/lib/rex/proto/smb.rb +++ b/lib/rex/proto/smb.rb @@ -1,15 +1,7 @@ -module Rex -module Proto -module SMB - - autoload :Constants, 'rex/proto/smb/constants' - autoload :Exceptions, 'rex/proto/smb/exceptions' - autoload :Evasions, 'rex/proto/smb/evasions' - autoload :Crypt, 'rex/proto/smb/crypt' - autoload :Utils, 'rex/proto/smb/utils' - autoload :Client, 'rex/proto/smb/client' - autoload :SimpleClient, 'rex/proto/smb/simpleclient' - -end -end -end +require 'rex/proto/smb/constants' +require 'rex/proto/smb/exceptions' +require 'rex/proto/smb/evasions' +require 'rex/proto/smb/crypt' +require 'rex/proto/smb/utils' +require 'rex/proto/smb/client' +require 'rex/proto/smb/simpleclient' \ No newline at end of file diff --git a/lib/rex/service_manager.rb b/lib/rex/service_manager.rb index 8cfc7d35ab..8beabd655c 100644 --- a/lib/rex/service_manager.rb +++ b/lib/rex/service_manager.rb @@ -1,5 +1,6 @@ require 'singleton' require 'rex' +require 'rex/service' module Rex diff --git a/lib/rex/socket.rb b/lib/rex/socket.rb index e3f46b2c0a..8bbc976f88 100644 --- a/lib/rex/socket.rb +++ b/lib/rex/socket.rb @@ -12,23 +12,19 @@ module Rex ### module Socket - # Plumbing / Aux - autoload :Parameters, 'rex/socket/parameters' - autoload :Comm, 'rex/socket/comm' + module Comm + end - # Underlying protocol-specific - autoload :Ip, 'rex/socket/ip' - autoload :Udp, 'rex/socket/udp' - autoload :Tcp, 'rex/socket/tcp' - autoload :TcpServer, 'rex/socket/tcp_server' - autoload :SslTcp, 'rex/socket/ssl_tcp' - autoload :SslTcpServer, 'rex/socket/ssl_tcp_server' + require 'rex/socket/parameters' + require 'rex/socket/tcp' + require 'rex/socket/tcp_server' - # Utilities - autoload :SwitchBoard, 'rex/socket/switch_board' - autoload :SubnetWalker, 'rex/socket/subnet_walker' - autoload :Range, 'rex/socket/range_walker' - autoload :RangeWalker, 'rex/socket/range_walker' + require 'rex/socket/comm' + require 'rex/socket/comm/local' + + require 'rex/socket/switch_board' + require 'rex/socket/subnet_walker' + require 'rex/socket/range_walker' ## # diff --git a/lib/rex/socket/comm.rb b/lib/rex/socket/comm.rb index 4510e329d0..efc86c7f5c 100644 --- a/lib/rex/socket/comm.rb +++ b/lib/rex/socket/comm.rb @@ -14,8 +14,6 @@ module Socket ### module Comm - autoload :Local, 'rex/socket/comm/local' - ### # # This mixin provides stubs for event notification handlers that can be diff --git a/lib/rex/socket/comm/local.rb b/lib/rex/socket/comm/local.rb index f9cb3f93c9..f1481c1337 100644 --- a/lib/rex/socket/comm/local.rb +++ b/lib/rex/socket/comm/local.rb @@ -1,6 +1,10 @@ -require 'rex/compat' -require 'rex/socket' require 'singleton' +require 'rex/socket' +require 'rex/socket/tcp' +require 'rex/socket/ssl_tcp' +require 'rex/socket/ssl_tcp_server' +require 'rex/socket/udp' +require 'rex/socket/ip' require 'timeout' ### diff --git a/lib/rex/sync.rb b/lib/rex/sync.rb index 543777fb28..da212e9dc2 100644 --- a/lib/rex/sync.rb +++ b/lib/rex/sync.rb @@ -1,6 +1,6 @@ -module Rex - autoload :ReadWriteLock, 'rex/sync/read_write_lock' - autoload :ThreadSafe, 'rex/sync/thread_safe' - autoload :Ref, 'rex/sync/ref' - autoload :Sync, 'rex/sync/event' -end +#!/usr/bin/env ruby + +require 'rex/sync/thread_safe' +require 'rex/sync/ref' +require 'rex/sync/read_write_lock' +require 'rex/sync/event' \ No newline at end of file diff --git a/lib/rex/ui.rb b/lib/rex/ui.rb index d35680e299..ec1cb87091 100644 --- a/lib/rex/ui.rb +++ b/lib/rex/ui.rb @@ -3,19 +3,19 @@ # wrappers of the rex library. # -require 'rex' +# General classes +require 'rex/ui/output' +require 'rex/ui/progress_tracker' -module Rex -module Ui - # General classes - autoload :Output, 'rex/ui/output' - autoload :ProgressTracker, 'rex/ui/progress_tracker' +# Text-based user interfaces +require 'rex/ui/text/input' +require 'rex/ui/text/shell' +require 'rex/ui/text/dispatcher_shell' +require 'rex/ui/text/irb_shell' - # Text-based user interfaces - autoload :Text, 'rex/ui/text' +require 'rex/ui/text/color' +require 'rex/ui/text/table' - # Ui subscriber - autoload :Subscriber, 'rex/ui/subscriber' - autoload :Interactive, 'rex/ui/interactive' -end -end +# Ui subscriber +require 'rex/ui/subscriber' +require 'rex/ui/interactive' \ No newline at end of file diff --git a/lib/rex/ui/text.rb b/lib/rex/ui/text.rb deleted file mode 100644 index c44a682e0d..0000000000 --- a/lib/rex/ui/text.rb +++ /dev/null @@ -1,17 +0,0 @@ -module Rex -module Ui -module Text - autoload :Input, 'rex/ui/text/input' - autoload :Output, 'rex/ui/text/output' - autoload :Color, 'rex/ui/text/color' - autoload :Table, 'rex/ui/text/table' - - autoload :PseudoShell, 'rex/ui/text/shell' - autoload :Shell, 'rex/ui/text/shell' - autoload :DispatcherShell, 'rex/ui/text/dispatcher_shell' - autoload :IrbShell, 'rex/ui/text/irb_shell' - - autoload :ProgressTracker, 'rex/ui/text/progress_tracker' -end -end -end diff --git a/lib/rex/ui/text/input.rb b/lib/rex/ui/text/input.rb index 8582114d81..cff4fb0a4e 100644 --- a/lib/rex/ui/text/input.rb +++ b/lib/rex/ui/text/input.rb @@ -13,10 +13,10 @@ module Text ### class Input - autoload :Buffer, 'rex/ui/text/color' - autoload :Stdio, 'rex/ui/text/input/stdio' - autoload :Readline, 'rex/ui/text/input/readline' - autoload :Socket, 'rex/ui/text/input/socket' + require 'rex/ui/text/input/stdio' + require 'rex/ui/text/input/readline' + require 'rex/ui/text/input/socket' + require 'rex/ui/text/color' include Rex::Ui::Text::Color diff --git a/lib/rex/ui/text/output.rb b/lib/rex/ui/text/output.rb index 65078e666b..f81a265a93 100644 --- a/lib/rex/ui/text/output.rb +++ b/lib/rex/ui/text/output.rb @@ -12,10 +12,11 @@ module Text ### class Output < Rex::Ui::Output - autoload :Stdio, 'rex/ui/text/output/stdio' - autoload :Socket, 'rex/ui/text/output/socket' - autoload :Buffer, 'rex/ui/text/output/buffer' - autoload :File, 'rex/ui/text/output/file' + require 'rex/ui/text/output/stdio' + require 'rex/ui/text/output/socket' + require 'rex/ui/text/output/buffer' + require 'rex/ui/text/output/file' + require 'rex/ui/text/color' include Rex::Ui::Text::Color