I don't know that much about programming but I am trying to practice. I am trying to learn to work with Python and some of the current exploits that are in BT. I am practicing taking some of the exploits out of Metasploit and convert them over to Python.

On some of the stack overflows, a stack adjustment is made because there is not enough free code to enclose a usable payload.

Code:
'Payload'        =>
                  {
		   'Space'    => 250,
                  'BadChars' => \x00\x20\x0a\x0d",
                  'StackAdjustment' => -3500,
		   }
After doing research the 'StackAdjustment' causes the framework to prepend an add esp, -3500 to the payload.

My question is what would be the coding syntax be in Python?

(3500 - len(shellcode)) ?

Or would it be something like the example I found here: h t t p://en.wikipedia.org/wiki/Stack_(data_structure)? Or is there a simpler way to do this? Any info is appreciated.

Code:
 class Stack(object):
    def __init__(self):
        self.stack_pointer = None
 
    def push(self, element):
        self.stack_pointer = Node(element, self.stack_pointer)
 
    def pop(self):
        e = self.stack_pointer.element
        self.stack_pointer = self.stack_pointer.next
        return e
 
    def peek(self):
        return self.stack_pointer.element
 
    def __len__(self):
        i = 0
        sp = self.stack_pointer
        while sp:
            i += 1
            sp = sp.next
        return i
 
class Node(object):
    def __init__(self, element=None, next=None):
        self.element = element
        self.next = next
 
if __name__ == '__main__':
    # small use example
    s = Stack()
    [s.push(i) for i in xrange(10)]
    print [s.pop() for i in xrange(len(s))]