Gray Noneya
Gray Noneya

Reputation: 89

Failed to parse arguments

I'm trying to run this code:

os.system("""gnome-terminal -e 'bash -c "arpspoof -i " + inter + " -t " + target + " " + gateway" ' """)

and the error is:

"Failed to parse arguments: Argument to "--command/-e" is not a valid command: Text ended before matching quote was found for ". (The text was 'bash -c "arpspoof -i " + inter + " -t " + target + " " + gateway" ')"

Here's my entire code:

import os
import time

def drift():
    global gateway
    gateway = raw_input("Gateway IP > ")
    time.sleep(0.5)
    global target
    target = raw_input("Target IP > ")
    time.sleep(0.5)
    global inter
    inter = raw_input("Interface > ")
drift()

os.system("""gnome-terminal -e 'bash -c "arpspoof -i " + inter + " -t " +   target + " " + gateway" ' """)

So for those of you who don't know what "Driftnet" is, its a MITM attack program to pick up pictures. To set it up you have to type in one terminal

"arpspoof -i -t "

Then open a new terminal and type the same thing but with the order of gateway IP and target IP switched, to trick your target into thinking you're a router.

I want my program to ask for gateway IP, target IP, interface, then run "arpspoof -i -t "

Then open a new terminal and and type out the same thing except switch the order of the gateway IP and target IP to where the target is first and gateway is second without the user having to type anything, and I'm trying to use os.system("""gnome-terminal -e 'bash -c "arpspoof -i " + inter + " -t " + target + " " + gateway" ' """) to do that, but it returns the error:

"Failed to parse arguments: Argument to "--command/-e" is not a valid command: Text ended before matching quote was found for ". (The text was 'bash -c "arpspoof -i " + inter + " -t " + target + " " + gateway" ')"

Thanks.

Upvotes: 1

Views: 6215

Answers (1)

Morgan Thrapp
Morgan Thrapp

Reputation: 9986

The issue is that you're trying to add strings in a triple quoted string. You seem to be trying to put the value of your variables into your triple quoted string, but you're actually passing the literal string gnome-terminal -e 'bash -c "arpspoof -i " + inter + " -t " + target + " " + gateway" ' to os.system().

What you need to do is use format.

os.system("""gnome-terminal -e 'bash -c "arpspoof -i {inter} -t {target} {gateway}" ' """.format(inter=inter, target=target, gateway=gateway))

Upvotes: 2

Related Questions