Skip to content

Commit

Permalink
Merge pull request #5 from tabassassin/retab/pr/2325
Browse files Browse the repository at this point in the history
Retab/pr/2325
  • Loading branch information
jlee-r7 committed Sep 5, 2013
2 parents 50c6f26 + 896bb12 commit 6725786
Show file tree
Hide file tree
Showing 3,153 changed files with 524,447 additions and 524,458 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 3 additions & 1 deletion data/meterpreter/ext_server_stdapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def channel_create_stdapi_fs_file(request, response):
fmode = packet_get_tlv(request, TLV_TYPE_FILE_MODE)
if fmode:
fmode = fmode['value']
fmode = fmode.replace('bb', 'b')
else:
fmode = 'rb'
file_h = open(fpath, fmode)
Expand All @@ -320,6 +321,7 @@ def channel_create_stdapi_net_tcp_client(request, response):
connected = False
for i in range(retries + 1):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(3.0)
if local_host.get('value') and local_port.get('value'):
sock.bind((local_host['value'], local_port['value']))
try:
Expand Down Expand Up @@ -380,7 +382,7 @@ def stdapi_sys_process_execute(request, response):
if len(cmd) == 0:
return ERROR_FAILURE, response
if os.path.isfile('/bin/sh'):
args = ['/bin/sh', '-c', cmd, raw_args]
args = ['/bin/sh', '-c', cmd + ' ' + raw_args]
else:
args = [cmd]
args.extend(shlex.split(raw_args))
Expand Down
2 changes: 2 additions & 0 deletions data/meterpreter/meterpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,5 +404,7 @@ def create_response(self, request):
return resp

if not hasattr(os, 'fork') or (hasattr(os, 'fork') and os.fork() == 0):
if hasattr(os, 'setsid'):
os.setsid()
met = PythonMeterpreter(s)
met.run()
4 changes: 2 additions & 2 deletions lib/anemone/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ def skip_link?(link)
#
# Kills all active threads
#
def shutdown
def shutdown
@tentacles.each {|t| t.kill rescue nil }
@pages = nil
end
end

end
end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/anchors.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Anchors < Anemone::Extractors::Base

def run
doc.search( '//a[@href]' ).map { |a| a['href'] }
end
def run
doc.search( '//a[@href]' ).map { |a| a['href'] }
end

end
14 changes: 7 additions & 7 deletions lib/anemone/extractors/dirbuster.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class Anemone::Extractors::Dirbuster < Anemone::Extractors::Base

def run
return [] if page.code.to_i != 200
def run
return [] if page.code.to_i != 200

@@dirs ||= nil
@@dirs ||= nil

return @@dirs if @@dirs
@@dirs = IO.read( File.dirname( __FILE__ ) + '/dirbuster/directories' ).split( "\n" )
end
return @@dirs if @@dirs
@@dirs = IO.read( File.dirname( __FILE__ ) + '/dirbuster/directories' ).split( "\n" )
end
end
8 changes: 4 additions & 4 deletions lib/anemone/extractors/forms.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Forms < Anemone::Extractors::Base

def run
doc.search( '//form[@action]' ).map { |a| a['action'] }
end
def run
doc.search( '//form[@action]' ).map { |a| a['action'] }
end
end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/frames.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Frames < Anemone::Extractors::Base

def run
doc.css( 'frame', 'iframe' ).map { |a| a.attributes['src'].content rescue next }
end
def run
doc.css( 'frame', 'iframe' ).map { |a| a.attributes['src'].content rescue next }
end

end
86 changes: 43 additions & 43 deletions lib/anemone/extractors/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@

class Anemone::Extractors::Generic < Anemone::Extractors::Base

def run
URI.extract( doc.to_s, %w(http https) ).map do |u|
#
# This extractor needs to be a tiny bit intelligent because
# due to its generic nature it'll inevitably match some garbage.
#
# For example, if some JS code contains:
#
# var = 'http://blah.com?id=1'
#
# or
#
# var = { 'http://blah.com?id=1', 1 }
#
#
# The URI.extract call will match:
#
# http://blah.com?id=1'
#
# and
#
# http://blah.com?id=1',
#
# respectively.
#
if !includes_quotes?( u )
u
else
if html.include?( "'#{u}" )
u.split( '\'' ).first
elsif html.include?( "\"#{u}" )
u.split( '"' ).first
else
u
end
end
end
rescue
[]
end
def run
URI.extract( doc.to_s, %w(http https) ).map do |u|
#
# This extractor needs to be a tiny bit intelligent because
# due to its generic nature it'll inevitably match some garbage.
#
# For example, if some JS code contains:
#
# var = 'http://blah.com?id=1'
#
# or
#
# var = { 'http://blah.com?id=1', 1 }
#
#
# The URI.extract call will match:
#
# http://blah.com?id=1'
#
# and
#
# http://blah.com?id=1',
#
# respectively.
#
if !includes_quotes?( u )
u
else
if html.include?( "'#{u}" )
u.split( '\'' ).first
elsif html.include?( "\"#{u}" )
u.split( '"' ).first
else
u
end
end
end
rescue
[]
end

def includes_quotes?( url )
url.include?( '\'' ) || url.include?( '"' )
end
def includes_quotes?( url )
url.include?( '\'' ) || url.include?( '"' )
end

end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/links.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Links < Anemone::Extractors::Base

def run
doc.search( "//link[@href]" ).map { |a| a['href'] }
end
def run
doc.search( "//link[@href]" ).map { |a| a['href'] }
end

end
38 changes: 19 additions & 19 deletions lib/anemone/extractors/meta_refresh.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
class Anemone::Extractors::MetaRefresh < Anemone::Extractors::Base

def run
doc.search( "//meta[@http-equiv='refresh']" ).map do |url|
begin
_, url = url['content'].split( ';', 2 )
next if !url
unquote( url.split( '=', 2 ).last )
rescue
next
end
end
rescue
nil
end
def run
doc.search( "//meta[@http-equiv='refresh']" ).map do |url|
begin
_, url = url['content'].split( ';', 2 )
next if !url
unquote( url.split( '=', 2 ).last )
rescue
next
end
end
rescue
nil
end

def unquote( str )
[ '\'', '"' ].each do |q|
return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
end
str
end
def unquote( str )
[ '\'', '"' ].each do |q|
return str[1...-1] if str.start_with?( q ) && str.end_with?( q )
end
str
end

end
6 changes: 3 additions & 3 deletions lib/anemone/extractors/scripts.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Anemone::Extractors::Scripts < Anemone::Extractors::Base

def run
doc.search( '//script[@src]' ).map { |a| a['src'] }
end
def run
doc.search( '//script[@src]' ).map { |a| a['src'] }
end

end
8 changes: 4 additions & 4 deletions lib/anemone/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def self.extractors
def run_extractors
return [] if !doc
self.class.extractors.map do |e|
next if e == Extractors::Dirbuster && !dirbust?
e.new( self ).run rescue next
next if e == Extractors::Dirbuster && !dirbust?
e.new( self ).run rescue next
end.flatten.
compact.map do |p|
abs = to_absolute( URI( p ) ) rescue next
Expand Down Expand Up @@ -186,7 +186,7 @@ def to_absolute(link)
end

def dirbust?
@dirbust
@dirbust
end

#
Expand Down Expand Up @@ -240,7 +240,7 @@ def self.from_hash(hash)
end

def dup
Marshal.load( Marshal.dump( self ) )
Marshal.load( Marshal.dump( self ) )
end

end
Expand Down
46 changes: 23 additions & 23 deletions lib/anemone/rex_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fetch_pages(url, referer = nil, depth = nil)
)
# Store the associated raw HTTP request
page.request = response.request
pages << page
pages << page
end

return pages
Expand Down Expand Up @@ -162,11 +162,11 @@ def get_response(url, referer = nil)
response = nil
request = nil
begin
conn = connection(url)
request = conn.request_raw(opts)
response = conn.send_recv(request, @opts[:timeout] || 10 )
rescue ::Errno::EPIPE, ::Timeout::Error
end
conn = connection(url)
request = conn.request_raw(opts)
response = conn.send_recv(request, @opts[:timeout] || 10 )
rescue ::Errno::EPIPE, ::Timeout::Error
end

finish = Time.now()

Expand All @@ -180,28 +180,28 @@ def get_response(url, referer = nil)
end

def connection(url)
context = { }
context['Msf'] = @opts[:framework] if @opts[:framework]
context['MsfExploit'] = @opts[:module] if @opts[:module]

conn = Rex::Proto::Http::Client.new(
url.host,
url.port.to_i,
context,
url.scheme == "https",
'SSLv23',
@opts[:proxies],
context = { }
context['Msf'] = @opts[:framework] if @opts[:framework]
context['MsfExploit'] = @opts[:module] if @opts[:module]

conn = Rex::Proto::Http::Client.new(
url.host,
url.port.to_i,
context,
url.scheme == "https",
'SSLv23',
@opts[:proxies],
@opts[:username],
@opts[:password]
)
)

conn.set_config(
'vhost' => virtual_host(url),
'agent' => user_agent,
conn.set_config(
'vhost' => virtual_host(url),
'agent' => user_agent,
'domain' => @opts[:domain]
)
)

conn
conn
end

def verbose?
Expand Down
Loading

0 comments on commit 6725786

Please sign in to comment.