Skip to content

Commit 68e8240

Browse files
author
zhaochengyu
committed
修复TCP首次连接可能被重置的问题
1 parent 00af7c3 commit 68e8240

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

readme.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ SLEEP_TIME = 0.01
5757
[ADVANCED-CONFIG]
5858
SOCKS5 = True
5959
```
60-
* 将stinger_server.exe和config.ini上传到目标服务器同一目录,菜刀(蚁剑)执行mirror_server.exe启动服务端
60+
* 将stinger_server.exe和config.ini上传到目标服务器同一目录,菜刀(蚁剑)执行stinger_server.exe启动服务端
6161
* stinger_client和config.ini拷贝到本地PC的同一目录,命令行执行stinger_client,生成如下输出表示成功
6262
```
6363
2019-09-29 13:03:41,164 - INFO - 215 - Use SERVER_LISTEN as REMOTE_SERVER
@@ -86,7 +86,9 @@ SOCK5: True
8686
* 此时已经你本地10800启动了一个192.168.3.10所在内网的socks5代理
8787
# 相关工具
8888
[https://github.com/nccgroup/ABPTTS](https://github.com/nccgroup/ABPTTS)
89+
8990
[https://github.com/sensepost/reGeorg](https://github.com/sensepost/reGeorg)
91+
9092
[https://github.com/SECFORCE/Tunna](https://github.com/SECFORCE/Tunna)
9193
# 已测试
9294
## stinger_server\stinger_client
@@ -101,3 +103,13 @@ SOCK5: True
101103
更新时间: 2019-09-29
102104
* 1.0正式版发布
103105

106+
**1.1**
107+
更新时间: 2019-10-25
108+
* 增加SOCKET_TIMEOUT参数
109+
* 适配https网站
110+
* 服务端增加socket重试机制,增强socket健壮性
111+
112+
**1.2**
113+
更新时间: 2019-11-23
114+
* 修复TCP首次连接可能被重置的问题
115+

stinger_client.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,26 @@ def sync_data(self):
159159
if CLEAN_DIE:
160160
for client_address in list(cache_conns.keys()):
161161
if web_return_data.get(client_address) is None:
162-
logger.warning("CLIENT_ADDRESS:{} remove client not in server cache_conns".format(client_address))
163-
self.die_client_address.append(client_address)
162+
if cache_conns.get(client_address).get("new") is True:
163+
cache_conns[client_address]["new"] = False
164+
pass
165+
else:
166+
logger.warning(
167+
"CLIENT_ADDRESS:{} remove client not in server CHCHE_CONNS".format(client_address))
168+
logger.warning("CLIENT_ADDRESS:{} append in die_client_address".format(client_address))
169+
self.die_client_address.append(client_address)
170+
164171

165172

166173
class TCPClient(BaseRequestHandler):
167174
def handle(self):
168175
logger.warning('Got connection from {}'.format(self.client_address))
169176
self.request.settimeout(SOCKET_TIMEOUT)
170177
key = "{}:{}".format(self.client_address[0], self.client_address[1])
171-
cache_conns[key] = {"conn": self.request}
178+
cache_conns[key] = {
179+
"conn": self.request,
180+
"new": True, # 新的连接,第一次检查略过
181+
}
172182
while True:
173183
time.sleep(10) # 维持tcp连接
174184

@@ -198,7 +208,7 @@ def handle(self):
198208
READ_BUFF_SIZE = int(configini.get("TOOL-CONFIG", "READ_BUFF_SIZE"))
199209
except Exception as E:
200210
logger.exception(E)
201-
READ_BUFF_SIZE = 10240
211+
READ_BUFF_SIZE = 51200
202212

203213
try:
204214
SLEEP_TIME = float(configini.get("TOOL-CONFIG", "SLEEP_TIME"))
@@ -208,7 +218,6 @@ def handle(self):
208218
logger.exception(E)
209219
SLEEP_TIME = 0.1
210220

211-
READ_BUFF_SIZE = 10240
212221

213222
# socket_timeout
214223
try:

webshell/proxy.jsp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
} catch (Exception e) {
2929
System.out.println("error to send post!" + e);
30-
return e.toString();
30+
return "30" + e.toString();
3131
} finally {
3232
try {
3333
if (ou != null) {
@@ -37,7 +37,7 @@
3737
in.close();
3838
}
3939
} catch (IOException ex) {
40-
return ex.toString();
40+
return "40" +ex.toString();
4141
}
4242
}
4343
return result;

0 commit comments

Comments
 (0)