Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8247739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:57:13+00:00 2026-06-07T22:57:13+00:00

i have a problem when using my code with threading, the problem is apparently

  • 0

i have a problem when using my code with threading, the problem is apparently that the variables i define outside of the threading part aren’t defined inside the threading part, here is my code:

import sys
import socket
from time import sleep
import threading

ip = raw_input ("please insert host ip: ")
port = input ("please insert port to fuzz: ")
header = raw_input ("please enter the header you want to fuzz, put & in the place you want to fuzz: ")
packet = raw_input ("what string would you like to fuzz the header with? : ")
multi = input ("in what jumps would you liike to multiply the string ? : ")
process = input ("please insert number of threads: ")
host = ip, port
char = packet * multi
a = 1

class ConnectionThread ( threading.Thread ):
    def run ( self ):
        while a > 0:
            try:
                s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
                s.connect((host))
                header = header.replace("&", packet)
                s.send(header)
                s.settimeout(7)
                data = s.recv(4)
                if data > 0:
                    print "got awnser"
                else:
                    print "no awnser"   
                sleep(0.1) 
                print "Fuzzing With:", header
                header = header.replace (packet, "&")
                packet = char + packet 
                s.close()
            except Exception as e:
                print e   
                s.close()
                sys.exit(0)
for x in xrange ( process ):
   ConnectionThread().start()

and i get this as return

local variable 'header' referenced before assignment
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:57:14+00:00Added an answer on June 7, 2026 at 10:57 pm

    You will need to give your ConnectionThread class the attributes that you want to pass to it. At the top of the class just put in a init method, this will define the variable that you want to pass to the run method:

    import sys
    import socket
    from time import sleep
    import threading
    
    class ConnectionThread ( threading.Thread ):
        def __init__(self):
            self.ip = raw_input ("please insert host ip: ")
            self.port = input ("please insert port to fuzz: ")
            self.header = raw_input ("please enter the header you want to fuzz, put & in the place you want to fuzz: ")
            self.packet = raw_input ("what string would you like to fuzz the header with? : ")
            self.multi = input ("in what jumps would you liike to multiply the string ? : ")
            self.process = input ("please insert number of threads: ")
            self.host = self.ip, self.port
            self.char = self.packet * self.multi
            self.a = 1
    
        def run ( self ):
            while self.a > 0:
                try:
                    s = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
                    s.connect((self.host))
                    self.header = self.header.replace("&", self.packet)
                    s.send(self.header)
                    s.settimeout(7)
                    data = s.recv(4)
                    if data > 0:
                        print "got awnser"
                    else:
                        print "no awnser"   
                    sleep(0.1) 
                    print "Fuzzing With:", header
                    self.header = self.header.replace (self.packet, "&")
                    self.packet = self.char + self.packet 
                    s.close()
                except Exception as e:
                    print e   
                    s.close()
                    sys.exit(0)
    
    for x in xrange ( ConnectionThread.process ):
       ConnectionThread().start()
    

    have a look at how classes work at:

    http://docs.python.org/tutorial/classes.html

    for additional information.

    Hope this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem using JSON and arrays. Here is my code: while($row =
I have a code problem which stems from the fact that I am using
i have a problem using the Catch Clipboard Events code found on this link
I have problem with javascript code. I am using google maps and I am
I have a problem trying to turn my python code into an executable using
I have a problem with my code in Android. I am using this to
I have this simple code, using Joda-time. Works fine, but I have a problem.
I am using gettext in my PHP code, but I have a big problem.
I am using a backgroundworker that can have n instances. Problem is the DoWork
I have problem installing simple Windows Service, my code looks like this: using System;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.