Skip to content

Commit d4b0f40

Browse files
committed
java add --request-template support
1 parent 985c47d commit d4b0f40

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

neoreg.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -982,11 +982,11 @@ def choice_useragent():
982982
request_template_start_index = 0
983983
request_template_end_index = 0
984984
if request_template:
985-
use_request_template = 'true'
985+
use_request_template = 1
986986
request_template_start_index = len(request_template[0])
987-
request_template_end_index = - len(request_template[1])
987+
request_template_end_index = len(request_template[1])
988988
else:
989-
use_request_template = 'false'
989+
use_request_template = 0
990990

991991
for filename in os.listdir(script_dir):
992992
outfile = os.path.join(outdir, filename)
@@ -998,6 +998,8 @@ def choice_useragent():
998998
text = re.sub(r"\bHTTPCODE\b", str(args.httpcode), text)
999999
text = re.sub(r"\bREADBUF\b", str(READBUF), text)
10001000
text = re.sub(r"\bMAXREADSIZE\b", str(MAXREADSIZE), text)
1001+
1002+
# request template
10011003
text = re.sub(r"USE_REQUEST_TEMPLATE", str(use_request_template), text)
10021004
text = re.sub(r"START_INDEX", str(request_template_start_index), text)
10031005
text = re.sub(r"END_INDEX", str(request_template_end_index), text)

templates/NeoreGeorg.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public boolean equals(Object obj) {
3535
String GeorgHello = (String) args[7];
3636
int BLV_L_OFFSET = (Integer) args[8];
3737

38+
int USE_REQUEST_TEMPLATE = (Integer) args[9];
39+
int START_INDEX = (Integer) args[10];
40+
int END_INDEX = (Integer) args[11];
41+
3842
int DATA = 1;
3943
int CMD = 2;
4044
int MARK = 3;
@@ -50,6 +54,8 @@ public boolean equals(Object obj) {
5054

5155
Object[] info = new Object[40];
5256
Object[] rinfo = new Object[40];
57+
String requestDataHead = "";
58+
String requestDataTail = "";
5359
try {
5460
if (((int)(Integer)(invokeMethod(request, "getContentLength", new Object[0]))) != -1) {
5561
String inputData = "";
@@ -63,11 +69,19 @@ public boolean equals(Object obj) {
6369
break;
6470
inputData += new String(buff);
6571
}
72+
if (USE_REQUEST_TEMPLATE == 1) {
73+
requestDataHead = inputData.substring(0, START_INDEX);
74+
requestDataTail = inputData.substring(inputData.length() - END_INDEX, inputData.length());
75+
76+
inputData = inputData.substring(START_INDEX);
77+
inputData = inputData.substring(0, inputData.length() - END_INDEX);
78+
}
6679
byte[] data = b64de(inputData);
6780
info = blv_decode(data, BLV_L_OFFSET);
6881
}
6982
} catch ( Exception e) {
70-
out.write(new String(b64de(GeorgHello)));
83+
// out.write(new String(b64de(GeorgHello)));
84+
out.write(e.toString());
7185
out.flush();
7286
out.close();
7387
return false; // exit
@@ -114,7 +128,7 @@ public boolean equals(Object obj) {
114128
return false;
115129
}
116130

117-
String newData = b64en(blv_encode(info, BLV_L_OFFSET));
131+
String newData = requestDataHead + b64en(blv_encode(info, BLV_L_OFFSET)) + requestDataTail;
118132
byte[] data = newData.getBytes();
119133
output.write(data, 0, data.length);
120134
output.flush();

0 commit comments

Comments
 (0)