執行一下程式,輸入python 路徑 -t 127.0.0.1 -p port
#127.0.0.1
import sys
import getopt
import socket
import threading
import subprocess
listen = false
command = false
upload = false
execute = ""
target = ""
upload_destination = ""
port = 0
def client_sender(buffer):
client = socket.socket(socket.af_inet,socket.sock_stream)
try:
client.connect((target,port))
if len(buffer):
client.send(buffer.encode())
while true:
recv_len = 1
response = ""
while recv_len:
# if you connect benji,you don't recv message
data = client.recv(4096)
recv_len = len(data)
response = response + data
if recv_len < 4096:
print "xiao yu 4096"
break
print response
break
except:
print "[*] exception exiting"
client.close()
def usage():
print "bhp net tool"
print "usage:bhpnet.py -t target_host -p port"
print "-i listen"
print "-e --execute=file_to_run"
print "-c -command"
print "-u --upload=destination"
print
print
print "example:"
print "bhpnet.py -t 192.168.0.1 -p 5555 -l -c"
print "bhpnet.py -t 192.168.0.1 -p 5555 -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.0.1 -p 135"
sys.exit(0)
def main():
global listen
global port
global execute
global command
global upload_destination
global target
if not len(sys.ar**[1:]):
usage()
try:
opts, args = getopt.getopt(sys.ar**[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"
if not listen and len(target) and port > 0:
buffer = sys.stdin.read()
client_sender(buffer)
if listen:
#server_loop()
print "woaini"
main()
命令列裡繼續輸入python 路徑
輸入這個最好在上一段**之前
因為服務端要比客戶端先開啟
以下這段**是服務端的
命令列引數處理
url url include include include include include struct student optsting是選項引數組成的字串,字元後跟乙個冒號,表明該選項要求有引數。static const char optstring i n h?option結構稱為長選項表...
Linux shel程式設計之命令列引數處理
在執行指令碼程式中,使用者可以通過命令列引數將引數傳遞給指令碼程式 test 10 a通過一些特殊的變數 位置引數,可以在指令碼中取得命令列引數。其中,0為程式名稱,1為第乙個引數,2為第二個引數,依此類推 9為第九個引數。cat test.sh bin bash echo shell name i...
shell指令碼程式設計 處理命令列引數
1 讀取引數 bash shell使用位置引數的特殊變數記錄命令列引數,0是程式名,1 9依次為輸入引數 如果指令碼需要多餘9個變數,需要將變數數字加花括號,如 命令列輸入的引數需要以空格分隔,當空格作為引數的一部分時可以使用引號分開 在指令碼中對命令列引數進行處理時需要對引數進行有效性判斷,如 1...