我正在练习一个教程代码,我被困在第29行(打印)必和必拓.py-t本地主机-p 9999-l-u=c:\目标.exe)在函数中,我不确定问题出在哪里。我一直在找工作内置.TabError:缩进中制表符和空格的使用不一致(必和必拓.py,第29行)我曾在谷歌上寻求帮助,但没有得到正确的答复。我曾试图寻找我的wing IDE只使用空格,但我仍然卡住了,因为我无法运行代码。我将非常感谢任何人的帮助,谁有什么问题是洞察,并能提供一个方法,我可以纠正它。下面是代码。。。你知道吗
import sys
import socket
import getopt
import threading
import subprocess
# define some global variables
listen = False
command = False
upload = False
execute = ''
target = ''
upload_destination = ''
port = 0
def usage():
print('BHP Net Tool')
print()
print('Usage: bhpnet.py -t target_host -p port')
print('-l --listen -listen on [host]:[port] for incoming connectiions')
print('-e --execute=file_to_run - execute the given file upon receiving a connection')
print('-c --command - initiate a command shell')
print('-u --upload=destination - upon receiving connection upload a file and write to [destination]')
print()
print()
print('Examples: ')
print('bhpnet.py -t 192.168.0.1 -p 5555 -l -c')
print('bhpnet.py -t localhost -p 9999 -l -u=c:\\target.exe')
print('bhpnet.py -t 192.168.0.1 -p 5555 -l -e=\'cat /etc/passwd''')
print('''echo 'ABCDEFGHI' | bhpnet.py -t 192.168.11.12 -p 135''')
sys.exit(0)
def main():
global listen
global port
global execute
global command
global upload_destination
global target
if not len(sys.argv[1:1]):
usage()
# read the command line options
try:
opts, args = getopt.getopt(sys.argv[1:],'hle:t:p:cu:', ['help','listen','execute','target','port','command','upload'])
except getopt.GetoptError as err:
print(str(err))
usage()
for o,a in opts:
if o in ('-h','--help'):
usage()
elif o in ('-l','--listen'):
listen = True
elif o in ('-e', '--execute'):
execute = a
elif o in ('-c', '--commandshell'):
command = True
elif o in ('-u', '--upload'):
upload_destination = a
elif o in ('-t', '--target'):
target = a
elif o in ('-p', '--port'):
port = int(a)
else:
assert False,'Unhandled Option'
# are we going to listen or just send data from stdin?
if not listen and len(target) and port > 0:
#read in the buffer from the commandline
# this will block, so send CTRL-D if not sending input
#to stdin
buffer = sys.stdin.read()
#send data off
client_sender(buffer)
#we are going to listen and potentially
#upload things, execute commands, and drop a shell back
#depending on our command line options above
if listen:
server_loop()
目前没有回答
相关问题 更多 >
编程相关推荐