Skip to content

Commit f7fb153

Browse files
committed
Adding some better heuristics into the checkSums
1 parent 360dc47 commit f7fb153

File tree

10 files changed

+805
-806
lines changed

10 files changed

+805
-806
lines changed

data/txt/sha256sums.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@ c4590a37dc1372be29b9ba8674b5e12bcda6ab62c5b2d18dab20bcb73a4ffbeb doc/translatio
125125
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 extra/dbgtool/__init__.py
126126
a777193f683475c63f0dd3916f86c4b473459640c3278ff921432836bc75c47f extra/dbgtool/README.txt
127127
b7557edb216f65056d359cd48f3191a642cf3a1838a422a67ffbef17b58535d7 extra/icmpsh/icmpsh.exe_
128-
2fcce0028d9dd0acfaec497599d6445832abad8e397e727967c31c834d04d598 extra/icmpsh/icmpsh-m.c
128+
4838389bf1ceac806dff075e06c5be9c0637425f37c67053a4361a5f1b88a65c extra/icmpsh/icmpsh-m.c
129129
8c38efaaf8974f9d08d9a743a7403eb6ae0a57b536e0d21ccb022f2c55a16016 extra/icmpsh/icmpsh-m.pl
130130
12014ddddc09c58ef344659c02fd1614157cfb315575378f2c8cb90843222733 extra/icmpsh/icmpsh_m.py
131-
1589e5edeaf80590d4d0ce1fd12aa176730d5eba3bfd72a9f28d3a1a9353a9db extra/icmpsh/icmpsh-s.c
131+
6359bfef76fb5c887bb89c2241f6d65647308856f8d3ce3e10bf3fdde605e120 extra/icmpsh/icmpsh-s.c
132132
ab6ee3ee9f8600e39faecfdaa11eaa3bed6f15ccef974bb904b96bf95e980c40 extra/icmpsh/__init__.py
133133
27af6b7ec0f689e148875cb62c3acb4399d3814ba79908220b29e354a8eed4b8 extra/icmpsh/README.txt
134134
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 extra/__init__.py
135135
191e3e397b83294082022de178f977f2c59fa99c96e5053375f6c16114d6777e extra/runcmd/README.txt
136136
53d98136e508330e3adad43e4a3b0ebc5143c79f0ee7bce5dacf92cb8f7a17fd extra/runcmd/runcmd.exe_
137137
70bd8a15e912f06e4ba0bd612a5f19a6b35ed0945b1e370f9b8700b120272d8f extra/runcmd/src/README.txt
138-
084aea8f337e1aed405a581603324ec01951eadcfd7b4eefaf3000b73f8b2e1e extra/runcmd/src/runcmd/runcmd.cpp
139-
e5c02d18abf544eebd18bd789121eaee4d638bae687402feafdd6daec18e82a1 extra/runcmd/src/runcmd/runcmd.vcproj
140-
7c2a12c21b61f727a2b3c6e85bd098e7f8a8b585a74b5eb31eb676ac776d5d57 extra/runcmd/src/runcmd.sln
141-
5e67c579a62715812a56731396d4cb432f16774a69f82629c6a3218174333605 extra/runcmd/src/runcmd/stdafx.cpp
142-
7bd768f3a742dcebddbe76de26eeee1438355d8600fb19dce945eef6486a3edb extra/runcmd/src/runcmd/stdafx.h
138+
baecf66c52fe3c39f7efa3a70f9d5bd6ea8f841abd8da9e6e11bdc80a995b3ae extra/runcmd/src/runcmd/runcmd.cpp
139+
a24d2dc1a5a8688881bea6be358359626d339d4a93ea55e8b756615e3608b8dd extra/runcmd/src/runcmd/runcmd.vcproj
140+
16d4453062ba3806fe6b62745757c66bf44748d25282263fe9ef362487b27db0 extra/runcmd/src/runcmd.sln
141+
d4186cac6e736bdfe64db63aa00395a862b5fe5c78340870f0c79cae05a79e7d extra/runcmd/src/runcmd/stdafx.cpp
142+
e278d40d3121d757c2e1b8cc8192397e5014f663fbf6d80dd1118443d4fc9442 extra/runcmd/src/runcmd/stdafx.h
143143
38f59734b971d1dc200584936693296aeebef3e43e9e85d6ec3fd6427e5d6b4b extra/shellcodeexec/linux/shellcodeexec.x32_
144144
b8bcb53372b8c92b27580e5cc97c8aa647e156a439e2306889ef892a51593b17 extra/shellcodeexec/linux/shellcodeexec.x64_
145145
cfa1f8d02f815c4e8561f6adbdd4e84dda6b6af6c7a0d5eeb9d7346d07e1e7ad extra/shellcodeexec/README.txt
@@ -167,7 +167,7 @@ e376093d4f6e42ee38b050af329179df9c1c136b7667b2f1cb559f5d4b69ebd9 lib/controller
167167
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/controller/__init__.py
168168
2a96190ced25d8929861b13866101812fcadf5cac23dd1dd4b29b1a915918769 lib/core/agent.py
169169
b13462712ec5ac07541dba98631ddcda279d210b838f363d15ac97a1413b67a2 lib/core/bigarray.py
170-
89b993f6f640baaf8ff27da0970963c3673e881552e2d142c1c30c4f7323e59d lib/core/common.py
170+
90b2abd849a15f6b75bae6bf650aecf70e4f2fec4c01776a22a0c3474b7ab6f2 lib/core/common.py
171171
a6397b10de7ae7c56ed6b0fa3b3c58eb7a9dbede61bf93d786e73258175c981e lib/core/compat.py
172172
a9997e97ebe88e0bf7efcf21e878bc5f62c72348e5aba18f64d6861390a4dcf2 lib/core/convert.py
173173
c03dc585f89642cfd81b087ac2723e3e1bb3bfa8c60e6f5fe58ef3b0113ebfe6 lib/core/data.py
@@ -188,7 +188,7 @@ c1cb56f2a43e9f2f6b25d5f3d504e856ea21df6fc14af5e37b1000feef2bdb5a lib/core/optio
188188
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
189189
0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py
190190
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
191-
db148648a411e4136dc4fefe15651c726ea3f718c27b53e413c3b850fb229b79 lib/core/settings.py
191+
1070a6f04c9fd65bfe323d5258f29d68804af178ab3a36702b8a3fd1f04a0239 lib/core/settings.py
192192
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
193193
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
194194
d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py

extra/icmpsh/icmpsh-m.c

Lines changed: 134 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,134 @@
1-
/*
2-
* icmpsh - simple icmp command shell
3-
* Copyright (c) 2010, Nico Leidecker <nico@leidecker.info>
4-
* This program is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU General Public License as published by
6-
* the Free Software Foundation, either version 3 of the License, or
7-
* (at your option) any later version.
8-
*
9-
* This program is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
17-
18-
#include <stdio.h>
19-
#include <stdlib.h>
20-
#include <sys/types.h>
21-
#include <sys/socket.h>
22-
#include <sys/stat.h>
23-
#include <netinet/in.h>
24-
#include <netinet/ip_icmp.h>
25-
#include <netinet/ip.h>
26-
#include <string.h>
27-
#include <unistd.h>
28-
#include <fcntl.h>
29-
30-
#define IN_BUF_SIZE 1024
31-
#define OUT_BUF_SIZE 64
32-
33-
// calculate checksum
34-
unsigned short checksum(unsigned short *ptr, int nbytes)
35-
{
36-
unsigned long sum;
37-
unsigned short oddbyte, rs;
38-
39-
sum = 0;
40-
while(nbytes > 1) {
41-
sum += *ptr++;
42-
nbytes -= 2;
43-
}
44-
45-
if(nbytes == 1) {
46-
oddbyte = 0;
47-
*((unsigned char *) &oddbyte) = *(u_char *)ptr;
48-
sum += oddbyte;
49-
}
50-
51-
sum = (sum >> 16) + (sum & 0xffff);
52-
sum += (sum >> 16);
53-
rs = ~sum;
54-
return rs;
55-
}
56-
57-
int main(int argc, char **argv)
58-
{
59-
int sockfd;
60-
int flags;
61-
char in_buf[IN_BUF_SIZE];
62-
char out_buf[OUT_BUF_SIZE];
63-
unsigned int out_size;
64-
int nbytes;
65-
struct iphdr *ip;
66-
struct icmphdr *icmp;
67-
char *data;
68-
struct sockaddr_in addr;
69-
70-
71-
printf("icmpsh - master\n");
72-
73-
// create raw ICMP socket
74-
sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
75-
if (sockfd == -1) {
76-
perror("socket");
77-
return -1;
78-
}
79-
80-
// set stdin to non-blocking
81-
flags = fcntl(0, F_GETFL, 0);
82-
flags |= O_NONBLOCK;
83-
fcntl(0, F_SETFL, flags);
84-
85-
printf("running...\n");
86-
while(1) {
87-
88-
// read data from socket
89-
memset(in_buf, 0x00, IN_BUF_SIZE);
90-
nbytes = read(sockfd, in_buf, IN_BUF_SIZE - 1);
91-
if (nbytes > 0) {
92-
// get ip and icmp header and data part
93-
ip = (struct iphdr *) in_buf;
94-
if (nbytes > sizeof(struct iphdr)) {
95-
nbytes -= sizeof(struct iphdr);
96-
icmp = (struct icmphdr *) (ip + 1);
97-
if (nbytes > sizeof(struct icmphdr)) {
98-
nbytes -= sizeof(struct icmphdr);
99-
data = (char *) (icmp + 1);
100-
data[nbytes] = '\0';
101-
printf("%s", data);
102-
fflush(stdout);
103-
}
104-
105-
// reuse headers
106-
icmp->type = 0;
107-
addr.sin_family = AF_INET;
108-
addr.sin_addr.s_addr = ip->saddr;
109-
110-
// read data from stdin
111-
nbytes = read(0, out_buf, OUT_BUF_SIZE);
112-
if (nbytes > -1) {
113-
memcpy((char *) (icmp + 1), out_buf, nbytes);
114-
out_size = nbytes;
115-
} else {
116-
out_size = 0;
117-
}
118-
119-
icmp->checksum = 0x00;
120-
icmp->checksum = checksum((unsigned short *) icmp, sizeof(struct icmphdr) + out_size);
121-
122-
// send reply
123-
nbytes = sendto(sockfd, icmp, sizeof(struct icmphdr) + out_size, 0, (struct sockaddr *) &addr, sizeof(addr));
124-
if (nbytes == -1) {
125-
perror("sendto");
126-
return -1;
127-
}
128-
}
129-
}
130-
}
131-
132-
return 0;
133-
}
134-
1+
/*
2+
* icmpsh - simple icmp command shell
3+
* Copyright (c) 2010, Nico Leidecker <nico@leidecker.info>
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include <stdio.h>
19+
#include <stdlib.h>
20+
#include <sys/types.h>
21+
#include <sys/socket.h>
22+
#include <sys/stat.h>
23+
#include <netinet/in.h>
24+
#include <netinet/ip_icmp.h>
25+
#include <netinet/ip.h>
26+
#include <string.h>
27+
#include <unistd.h>
28+
#include <fcntl.h>
29+
30+
#define IN_BUF_SIZE 1024
31+
#define OUT_BUF_SIZE 64
32+
33+
// calculate checksum
34+
unsigned short checksum(unsigned short *ptr, int nbytes)
35+
{
36+
unsigned long sum;
37+
unsigned short oddbyte, rs;
38+
39+
sum = 0;
40+
while(nbytes > 1) {
41+
sum += *ptr++;
42+
nbytes -= 2;
43+
}
44+
45+
if(nbytes == 1) {
46+
oddbyte = 0;
47+
*((unsigned char *) &oddbyte) = *(u_char *)ptr;
48+
sum += oddbyte;
49+
}
50+
51+
sum = (sum >> 16) + (sum & 0xffff);
52+
sum += (sum >> 16);
53+
rs = ~sum;
54+
return rs;
55+
}
56+
57+
int main(int argc, char **argv)
58+
{
59+
int sockfd;
60+
int flags;
61+
char in_buf[IN_BUF_SIZE];
62+
char out_buf[OUT_BUF_SIZE];
63+
unsigned int out_size;
64+
int nbytes;
65+
struct iphdr *ip;
66+
struct icmphdr *icmp;
67+
char *data;
68+
struct sockaddr_in addr;
69+
70+
71+
printf("icmpsh - master\n");
72+
73+
// create raw ICMP socket
74+
sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
75+
if (sockfd == -1) {
76+
perror("socket");
77+
return -1;
78+
}
79+
80+
// set stdin to non-blocking
81+
flags = fcntl(0, F_GETFL, 0);
82+
flags |= O_NONBLOCK;
83+
fcntl(0, F_SETFL, flags);
84+
85+
printf("running...\n");
86+
while(1) {
87+
88+
// read data from socket
89+
memset(in_buf, 0x00, IN_BUF_SIZE);
90+
nbytes = read(sockfd, in_buf, IN_BUF_SIZE - 1);
91+
if (nbytes > 0) {
92+
// get ip and icmp header and data part
93+
ip = (struct iphdr *) in_buf;
94+
if (nbytes > sizeof(struct iphdr)) {
95+
nbytes -= sizeof(struct iphdr);
96+
icmp = (struct icmphdr *) (ip + 1);
97+
if (nbytes > sizeof(struct icmphdr)) {
98+
nbytes -= sizeof(struct icmphdr);
99+
data = (char *) (icmp + 1);
100+
data[nbytes] = '\0';
101+
printf("%s", data);
102+
fflush(stdout);
103+
}
104+
105+
// reuse headers
106+
icmp->type = 0;
107+
addr.sin_family = AF_INET;
108+
addr.sin_addr.s_addr = ip->saddr;
109+
110+
// read data from stdin
111+
nbytes = read(0, out_buf, OUT_BUF_SIZE);
112+
if (nbytes > -1) {
113+
memcpy((char *) (icmp + 1), out_buf, nbytes);
114+
out_size = nbytes;
115+
} else {
116+
out_size = 0;
117+
}
118+
119+
icmp->checksum = 0x00;
120+
icmp->checksum = checksum((unsigned short *) icmp, sizeof(struct icmphdr) + out_size);
121+
122+
// send reply
123+
nbytes = sendto(sockfd, icmp, sizeof(struct icmphdr) + out_size, 0, (struct sockaddr *) &addr, sizeof(addr));
124+
if (nbytes == -1) {
125+
perror("sendto");
126+
return -1;
127+
}
128+
}
129+
}
130+
}
131+
132+
return 0;
133+
}
134+

0 commit comments

Comments
 (0)