Mostly cosmetic

git-svn-id: file:///home/svn/framework3/trunk@7530 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2009-11-16 15:16:08 +00:00
parent ba5da501bf
commit 8cadfe66cf
11 changed files with 81 additions and 77 deletions

View File

@ -19,11 +19,9 @@ end
# ActiveRecord/sqlite3 has locking issues when you update a table with a pending select
# This set of instance/class wrappers should prevent a table lock
# Straight up gangsta shit from spoon (ripped from BION)
# Straight up gangsta from spoon (ripped from BION)
module DBSave
def self.included(mod)
class << mod
def find(*args)

View File

@ -94,7 +94,7 @@ class Encoder < Module
#
AlphanumUnicodeMixed = "alpha_unicode_mixed"
#
# toupper/tolower safe ascii - not 'a' - 'z', 'A' - 'Z'
# toupper/tolower safe ascii - not 'a' - 'z', 'A' - 'Z'
#
NonAlpha = "non_alpha"
#
@ -109,7 +109,7 @@ class Encoder < Module
# May result in the generation of any characters
#
Unspecified = "unspecified"
#
#
# The raw payload passed to the encoder will be the same as the encoded
# payload
#
@ -265,7 +265,7 @@ class Encoder < Module
# initialized and is ready to go.
#
def do_encode(state)
# Copy the decoder stub since we may need to modify it
stub = decoder_stub(state).dup
@ -273,7 +273,7 @@ class Encoder < Module
# Substitute the decoder key in the copy of the decoder stub with the
# one that we found
real_key = state.key
# If we're using context encoding, the actual value we use for
# substitution is the context address, not the key we use for
# encoding
@ -283,17 +283,17 @@ class Encoder < Module
else
stub = encode_finalize_stub(state, stub)
end
# Walk the buffer encoding each block along the way
offset = 0
if (decoder_block_size)
while (offset < state.buf.length)
block = state.buf[offset, decoder_block_size]
state.encoded += encode_block(state,
state.encoded += encode_block(state,
block + ("\x00" * (decoder_block_size - block.length)))
offset += decoder_block_size
end
else
@ -306,8 +306,8 @@ class Encoder < Module
# Last but not least, do one last badchar pass to see if the stub +
# encoded payload leads to any bad char issues...
if ((badchar_idx = has_badchars?(state.encoded, state.badchars)) != nil)
raise BadcharError.new(state.encoded, badchar_idx, stub.length, state.encoded[badchar_idx]),
"The #{self.name} encoder failed to encode without bad characters.",
raise BadcharError.new(state.encoded, badchar_idx, stub.length, state.encoded[badchar_idx]),
"The #{self.name} encoder failed to encode without bad characters.",
caller
end
@ -393,7 +393,7 @@ protected
state.buf = state.orig_buf
end
#
#
# Obtains the key to use during encoding. If context encoding is enabled,
# special steps are taken. Otherwise, the derived class is given an
# opportunity to find the key.
@ -419,12 +419,12 @@ protected
bad_keys = find_bad_keys(buf, badchars)
found = false
allset = [*(0..255)]
# Keep chugging until we find something...right
while (!found)
# Scan each byte position
0.upto(decoder_key_size - 1) { |index|
# Subtract the bad and leave the good
good_keys = allset - bad_keys[index].keys
@ -438,7 +438,7 @@ protected
key_bytes[index] = good_keys[ rand(good_keys.length) ]
}
# Assume that we're going to rock this shit...
# Assume that we're going to rock this...
found = true
# Scan each byte and see what we've got going on to make sure
@ -448,7 +448,7 @@ protected
found = false
end
}
found = find_key_verify(buf, key_bytes, badchars) if found
end
@ -505,7 +505,7 @@ protected
# Pack it to byte form so that we can check each byte for
# bad characters
address_bytes = integer_to_key_bytes(address)
# Scan each byte and see what we've got going on to make sure
# no funny business is happening with the address
invalid_key = false
@ -563,14 +563,14 @@ protected
if (idx != nil)
return idx
end
end
}
return nil
end
#
# Convert individual key bytes into a single integer based on the
# Convert individual key bytes into a single integer based on the
# decoder's key size and packing requirements
#
def key_bytes_to_integer(key_bytes)
@ -585,7 +585,7 @@ protected
end
#
# Convert an integer into the individual key bytes based on the
# Convert an integer into the individual key bytes based on the
# decoder's key size and packing requirements
#
def integer_to_key_bytes(integer)
@ -608,3 +608,4 @@ require 'msf/core/encoder/xor_additive_feedback'
require 'msf/core/encoder/alphanum'
require 'msf/core/encoder/nonalpha'
require 'msf/core/encoder/nonupper'

View File

@ -13,7 +13,7 @@ class Xor
attr_accessor :raw, :encoded, :badchars, :opts, :key, :fkey # :nodoc:
#
# wrap that shit in a wanna be static class
# wrap that in a wanna be static class
#
def self.encode(*args)
self.new.encode(*args)
@ -65,4 +65,5 @@ class Xor
end
end end
end end

View File

@ -79,7 +79,7 @@ class DwordAdditive < Generic
# increment the offending key byte
key[strip] = key[strip] + 1 & 0xff
# fuck, we wrapped around!
# We wrapped around!
if key[strip] == kstart[strip]
raise KeySearchError, "Key space exhausted on strip #{strip}!", caller
end
@ -88,4 +88,5 @@ class DwordAdditive < Generic
return key
end
end end end end # DwordAdditive/Xor/Encoding/Rex
end end end end # DwordAdditive/Xor/Encoding/Rex

View File

@ -5,10 +5,7 @@ module Encoding
module Xor
module Exception
MSG = "Hoe's be frontin n shit"
def to_suck
self.class::MSG
end
end
class KeySearchError < ::Exception
@ -16,4 +13,5 @@ class KeySearchError < ::Exception
MSG = "Error finding a key."
end
end end end
end end end

View File

@ -22,7 +22,7 @@ module File
# inherits fd and mode from IO
attr_accessor :filename
public
# f = File.new("testfile", "r")
# f = File.new("newfile", "w+")
# f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
@ -37,7 +37,7 @@ module File
# ctime/atime blah need fstat..
# need lchown/chown/fchown, etc, etc
# proxy this crap, whatever
# proxy these methods
def File.basename(*a)
::File.basename(*a)
end
@ -48,7 +48,7 @@ module File
::File.extname(*a)
end
# !!! we might actually want to handle this File::SEPERATOR stuff
# for win32 support, etc. And you know, when we rock the vax n shit
# for win32 support, etc.
def File.join(*a)
::File.join(*a)
end
@ -168,4 +168,5 @@ module File
end
end; end # Post/Rex
end; end # Post/Rex

View File

@ -52,13 +52,13 @@ class Channel
def request_handler(client, packet)
cid = packet.get_tlv_value(TLV_TYPE_CHANNEL_ID)
# No channel identifier, then drop out 'n shit
# No channel identifier, then drop it
if (cid == nil)
return false
end
channel = client.find_channel(cid)
# Valid channel context?
if (channel == nil)
return false
@ -77,17 +77,17 @@ class Channel
end
end
##
##
#
# Factory
#
##
#
# Creates a logical channel between the client and the server
# Creates a logical channel between the client and the server
# based on a given type.
#
def Channel.create(client, type = nil, klass = nil,
def Channel.create(client, type = nil, klass = nil,
flags = CHANNEL_FLAG_SYNCHRONOUS, addends = nil)
request = Packet.create_request('core_channel_open')
@ -114,7 +114,7 @@ class Channel
# Create the channel instance
channel = klass.new(client, cid, type, flags)
return channel
end
@ -134,7 +134,7 @@ class Channel
self.type = type
self.flags = flags
# Add this instance to the list and shit
# Add this instance to the list
if (cid and client)
client.add_channel(self)
end
@ -173,7 +173,7 @@ class Channel
begin
response = self.client.send_request(request)
rescue
rescue
return nil
end
@ -413,10 +413,11 @@ protected
#
# Cleans up any lingering resources
#
#
def cleanup
end
end
end; end; end
end; end; end

View File

@ -18,7 +18,7 @@ module Net
# This class provides an interface to interacting with sockets
# on the remote machine. It allows callers to open TCP, UDP,
# and other arbitrary socket-based connections as channels that
# can then be interacted with through the established
# can then be interacted with through the established
# meterpreter connection.
#
###
@ -39,7 +39,7 @@ class Socket
self.monitored_sockets = []
self.monitored_socket_channels = {}
# Start monitoring shit like the business
# Start monitoring the sockets
self.monitor_sockets
end
@ -76,7 +76,7 @@ class Socket
# Add this channel's right socket to the socket monitor
add_monitored_socket(channel.rsock, channel)
# If we get a valid channel back, create a stream
# If we get a valid channel back, create a stream
# representation of the left side of the socket for
# the caller to use
if (channel != nil)
@ -138,14 +138,14 @@ protected
self.monitor_thread = ::Thread.new {
loop do
# Watch for data
begin
socks = select(monitored_sockets, nil, nil, 1)
rescue StreamClosedError => e
channel = monitored_socket_channels[e.stream.object_id]
dlog("monitor_channels: channel #{channel} closed (#{e.stream})",
dlog("monitor_channels: channel #{channel} closed (#{e.stream})",
'rex', LEV_3)
if (channel)
@ -226,4 +226,5 @@ protected
end
end; end; end; end; end; end
end; end; end; end; end; end

View File

@ -25,7 +25,7 @@ class Packet::Header < Hash
#
# Parses a header from a string.
#
# XXX - Putting : in a header value fucks this up pretty badly
# XXX - Putting : in a header value breaks this badly
def from_s(header)
reset
@ -36,10 +36,10 @@ class Packet::Header < Hash
end
# put the non-standard line terminations back to normal
# gah. not having look behinds suck,
# gah. not having look behinds suck,
header.gsub!(/([^\r])\n/,'\1' + "\r\n")
# undo folding, kinda ugly but works for now.
# undo folding, kinda ugly but works for now.
header.gsub!(/:\s*\r\n\s+/smi,': ')
# Extract the command string
@ -68,7 +68,7 @@ class Packet::Header < Hash
end
if (rv == nil)
begin
rv = self.dcase_hash[key.downcase]
rv = self.dcase_hash[key.downcase]
rescue IndexError
rv = nil
end
@ -99,12 +99,12 @@ class Packet::Header < Hash
#
def to_s(prefix = '')
str = prefix
if self.junk_headers
while str.length < 4096
if self.fold
str << "X-#{Rex::Text.rand_text_alphanumeric(rand(30) + 5)}:\r\n\t#{Rex::Text.rand_text_alphanumeric(rand(1024) + 1)}\r\n"
else
else
str << "X-#{Rex::Text.rand_text_alphanumeric(rand(30) + 5)}: #{Rex::Text.rand_text_alphanumeric(rand(1024) + 1)}\r\n"
end
end
@ -117,7 +117,7 @@ class Packet::Header < Hash
str << "#{var}: #{val}\r\n"
end
}
str << "\r\n"
return str
@ -146,7 +146,7 @@ class Packet::Header < Hash
# requests and responses.
#
attr_accessor :junk_headers
attr_accessor :cmd_string
attr_accessor :cmd_string
attr_accessor :fold
protected
@ -158,3 +158,4 @@ end
end
end
end

View File

@ -33,9 +33,9 @@ class ReadWriteLock
#
def lock_read
read_sync_mutex.lock
begin
# If there are a non-zero number of readers and a
# If there are a non-zero number of readers and a
# writer is waiting to acquire the exclusive lock,
# free up the sync mutex temporarily and lock/unlock
# the exclusive lock. This is to give the writer
@ -51,13 +51,13 @@ class ReadWriteLock
# Increment the active reader count
@readers += 1
# If we now have just one reader, acquire the exclusive
# If we now have just one reader, acquire the exclusive
# lock. Track the thread owner so that we release the
# lock from within the same thread context later on.
if (@readers == 1)
exclusive_mutex.lock
@owner = Thread.current
end
ensure
@ -79,8 +79,8 @@ class ReadWriteLock
while (!unlocked)
# If there are no more readers left after this one
if (@readers - 1 == 0)
# If the calling thread is the owner of the exclusive
# reader lock, then let's release that shit!
# If the calling thread is the owner of the exclusive
# reader lock, then let's release it
if (Thread.current == @owner)
@owner = nil
@ -117,7 +117,7 @@ class ReadWriteLock
@writer = true
exclusive_mutex.lock
@owner = Thread.current
ensure
write_sync_mutex.unlock
@ -172,4 +172,5 @@ protected
end
end
end

View File

@ -21,17 +21,17 @@ class Transformer
#
# Transformer.transform(string, Array, [ String ], target)
#
def Transformer.transform(src_instance, dst_class, supported_classes,
def Transformer.transform(src_instance, dst_class, supported_classes,
target = nil)
dst_instance = dst_class.new
if (src_instance.kind_of?(Array))
src_instance.each { |src_inst|
Transformer.transform_single(src_inst, dst_instance,
Transformer.transform_single(src_inst, dst_instance,
supported_classes, target)
}
elsif (!src_instance.kind_of?(NilClass))
Transformer.transform_single(src_instance, dst_instance,
Transformer.transform_single(src_instance, dst_instance,
supported_classes, target)
end
@ -43,15 +43,14 @@ protected
#
# Transform a single source instance.
#
def Transformer.transform_single(src_instance, dst_instance,
def Transformer.transform_single(src_instance, dst_instance,
supported_classes, target)
# If the src instance's class is supported, just add it to the dst
# If the src instance's class is supported, just add it to the dst
# instance
if (supported_classes.include?(src_instance.class))
dst_instance << src_instance
# If the src instance's class is an array, then we should check to see
# if any of the supporting classes support from_a. If they do, we'll
# call it and try to rock that shit, otherwise we'll bomb out.
# if any of the supporting classes support from_a.
elsif (src_instance.kind_of?(Array))
new_src_instance = nil
@ -73,7 +72,7 @@ protected
end
# If the source instance is a string, query each of the supported
# classes to see if they can serialize it to their particular data
# classes to see if they can serialize it to their particular data
# type.
elsif (src_instance.kind_of?(String))
new_src_instance = nil
@ -112,4 +111,5 @@ protected
end
end
end