Today I the dummy beginner programmer have this rather complex problem with which I need help.
I downloaded the famous hping2 tool, the executable together with its source code. Now as soon as I ran the executable on my windows vista I ran into the same problem again. The command console flashed on the screen for an instance and then quickly closed itself and disappeared.
So I decided to learn to recompile the source code as I know that many of you do. I wanted to learn to fix the source code so that the program can work on my vista. First of all I replaced the last line "return 0;" with "system("PAUSE"); return EXIT_SUCCESS;" in the main.c, thinking that that would fix the problem of the console immediately disappearing upon being opened. But as soon as I compiled the code a ton of compiler errors appeared. i was surprised: the author of the program is a famous expert, isn't he? I here give you the source code in main.c of this program (which contains like 50 or so other source files and header files) and the first half of the compile log showing the compiler errors.
/
* $smu-mark$
* $name: main.c$
* $author: Salvatore Sanfilippo <antirez@invece.org>$
* $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
* $license: This software is under GPL version 2 of license$
* $date: Fri Nov 5 11:55:48 MET 1999$
* $rev: 8$ /
/
* hping official page at http://www.kyuzz.org/antirez
* Covered by GPL version 2, Read the COPYING file for more information /
/ open raw socket /
sockraw = open_sockraw();
if (sockraw == -1) {
printf("[main] can't open raw socket\n");
ifdef WIN32
WSACleanup();
endif
exit(1);
}
/ set SO_BROADCAST option /
socket_broadcast(sockraw);
/ set SO_IPHDRINCL option /
socket_iphdrincl(sockraw);
/* open sock packet or libpcap socket */
if (defined OSTYPE_LINUX) && (!defined FORCE_LIBPCAP)
sockpacket = open_sockpacket();
if (sockpacket == -1) {
printf("[main] can't open packet socket\n");
exit(1);
}
else
if (open_pcap() == -1) {
printf("[main] open_pcap failed\n");
ifdef WIN32
WSACleanup();
endif
exit(1);
}
endif / OSTYPE_LINUX && !FORCE_LIBPCAP /
/* get physical layer header size */if(get_linkhdr_size(ifname)==-1){printf("[main]physicallayerheadersizeunknown\n");exit(1);}if(spoofaddr[0]=='\0')resolve((structsockaddr*)&local,ifstraddr);elseresolve((structsockaddr*)&local,spoofaddr);if(icmp_ip_srcip[0]=='\0')resolve((structsockaddr*)&icmp_ip_src,"1.2.3.4");elseresolve((structsockaddr*)&icmp_ip_src,icmp_ip_srcip);if(icmp_ip_dstip[0]=='\0')resolve((structsockaddr*)&icmp_ip_dst,"5.6.7.8");elseresolve((structsockaddr*)&icmp_ip_dst,icmp_ip_dstip);if(icmp_gwip[0]=='\0')resolve((structsockaddr*)&icmp_gw,"0.0.0.0");elseresolve((structsockaddr*)&icmp_gw,icmp_gwip);
srand(time(NULL));/* set initial source port */if(initsport==-1)initsport=src_port=1024+(rand()%2000);elsesrc_port=initsport;for(c=0;c<TABLESIZE;c++)delaytable[c].seq=-1;
ifndef WIN32
/ use SIGALRM to send packets like ping do /
Signal(SIGALRM, send_packet);
/* if we are in listemode enter in listenmain() else *//* print HPING... bla bla bla and enter in wait_packet() */if(opt_listenmode){fprintf(stderr,"hpinglistenmode\n");/* memory protection */if(memlockall()==-1){perror("[main]memlockall()");fprintf(stderr,"Warning:can'tdisablememorypaging!\n");}elseif(opt_verbose||opt_debug){printf("Memorypagingdisabled\n");}listenmain();/* UNREACHED */}/* Scan mode */if(opt_scanmode){fprintf(stderr,"Scanning%s(%s),port%s\n",targetname,targetstraddr,opt_scanports);scanmain();/* UNREACHED */}if(opt_rawipmode){strcat(setflags,"rawIPmode");hdr_size=IPHDR_SIZE;}
else if (opt_icmpmode) {
strcat(setflags, "icmp mode");
hdr_size = IPHDR_SIZE + ICMPHDR_SIZE;
}
else if (opt_udpmode) {
strcat(setflags, "udp mode");
hdr_size = IPHDR_SIZE + UDPHDR_SIZE;
}
else {
if (tcp_th_flags & TH_RST) strcat(setflags, "R");
if (tcp_th_flags & TH_SYN) strcat(setflags, "S");
if (tcp_th_flags & TH_ACK) strcat(setflags, "A");
if (tcp_th_flags & TH_FIN) strcat(setflags, "F");
if (tcp_th_flags & TH_PUSH) strcat(setflags, "P");
if (tcp_th_flags & TH_URG) strcat(setflags, "U");
if (tcp_th_flags & TH_X) strcat(setflags, "X");
if (tcp_th_flags & TH_Y) strcat(setflags, "Y");
if (setflags[0] == '\0') strcat(setflags, "NO FLAGS are");
hdr_size = IPHDR_SIZE + TCPHDR_SIZE;
}
/
* Set a Windows timer to send packets. Replacement for signal SIGALRM under
* Unix. /
/ if (opt_waitinusec == FALSE)
setTimer(send_packet, sending_wait * 1000, TIME_PERIODIC);
else
setTimer(send_packet, msec_delay.millitm, TIME_PERIODIC);/
initPeriod();
setTimer(send_packet, sending_wait * 10, TIME_ONESHOT);
endif
/* main loop */while(1){wait_packet();
ifdef WIN32
if (ctrlzbind != BIND_NONE)
win_ctrl_z(keyboard_handle);
endif
}
system("PAUSE");
return EXIT_SUCCESS;
}
Now the first half of the compiler log:
compiler: default compiler
building makefile: "...\desktop\hping2win32\makefile.win"
executing make...
c:\dev-cpp\bin\make.exe -f "c:...\desktop\hping2win32\makefile.win" all
c:\dev-cpp\bin\gcc.exe -c main.c -o main.o -|"c:/dev-cpp/include" -Di386 -02
in file included from main.c:42
hping2.h:29:18:pcap.h:no such file or directory
in file included from hping2h:71
from main c:42
hcmp.h:20: error: syntax error before "u_int8_t"
hcmp.h:20: warning: no semicolon at end of struct or union
hcmp.h:23: erorr: syntax error before "u_int16_t"
hcmp:h:23: warning: no semicolon at end of struct or union
hcmp:h:24: warning: data definition has no type or storage class
hcmp:h:25: warning: data definition has no type or storage class
hcmp:h:26: error: syntax error before '}' token
in file included from main.c:42
hping2h:281: error syntax error before "u_int8_t"
hping2h:281: warning: no semicolon at end of struct or union
hping2h:289: warning: data definition has no type or storage class
hping2h:290: error: syntax error before "tot_len"
hping2h: 290: warning: data definition has no type or storage class
hping2h: 291: error: syntax error before "id"
hping2h: 291: warning: data definition has no type or storage class
hping2h: 292: error: syntax error before "frag_off"
hping2h: 292: warning: data definition has no type or storage class
hping2h: 293: error: syntax error before "ttl"
hping2h: 293: warning: data definition has no type or storage class
hping2h: 294: error: syntax error before "protocol"
hping2h: 294: warning: data definition has no type or storage class
hping2h: 295: error: syntax error before "check"
hping2h: 295: warning: data definition has no type or storage class
hping2h: 296: error: syntax error before "saddr"
hping2h: 296: warning: data definition has no type or storage class
hping2h: 297: error: syntax error before "daddr"
hping2h: 297: warning: data definition has no type or storage class
hping2h: 304: error: syntax error before "u_int16_t"
hping2h: 304: warning: no semicolon at end of struct or union
hping2h: 305: warning: data definition has no type or storage class
hping2h: 306: error: syntax error before "uh_ulen"
hping2h: 306: warning: data definition has no type or storage class
hping2h: 307: error: syntax error before "uh_sum"
hping2h: 307: warning: data definition has no type or storage class
hping2h: 315: error: syntax error before "u_int16_t"
hping2h: 315: warning: no semicolon at end of struct or union
hping2h: 316: warning: data definition has no type or storage class
hping2h: 317: error: syntax error before "th_seq"
hping2h: 317: warning: data definition has no type or storage class
hping2h: 318: error: syntax error before "th_ack"
hping2h: 318: warning: data definition has no type or storage class
hping2h: 320: error: syntax error before "th_x2"
hping2h: 328: warning: data definition has no type or storage class
hping2h: 329: error: syntax error before "th_win"
....................
The compiler log goes on and on without end, so I want to learn to fix the source codes little by little first. My very first problem is: it says that there is no pcap.h file or directory. Okay, I see that it's true that the whole hping2 source code does not contain a pcap.h. But I already have libpcap source code on my computer, so I just moved the pcap.h from libpcap folder to hping2 folder. But no use, the comiler still issues "pcap.h, no such file or directory." Now how to fix this problem?
The other questions will come later, please don't mind my super long question.
Will really appreciate someone's expert help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well you could try placing hping.exe in a simpler path. Are you sure you got the path right? How about the right command name!? The documentation clearly shows the command being "hping2" not "hping". And as I said, hping requires command line parameters, and you never gave it any in any case!
<Bangs head against wall repeatedly>
You should CD to it first, just to make life easier:
> cd C:\Users[my computer name]\Desktop\hping2win32
> hping2 <hostename>
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't have Vista (and don't plan on getting it anytime soon), so I'll have to wing this, someone else with Vista may be able to tell you exactly where to pull this up.
Find the "Run..." command, used to be in the start menu, but since Vista doesn't have a "Start", look in the round thing in the lower left. Enter either "cmd" or "command" (I don't know which one Vista accepts.) in the space provided and press the enter key.
The black console window will open and it will stay open until you close it. At the C:\ prompt enter the path to the executable program. You did not say what it is called, but I'm assuming it is called hping2.exe. That is, if hping2.exe is located directly on your C:\ drive enter at the prompt "hping2" (without the .exe suffix or the quotation marks). The program should run.
Since you are an admitted novice, compiling this code is probably something you should wait on until you know how to do it with simpiler code. Just by looking at the small bit you copied and pasted I can see that it was designed to be compiled for use by either Windows or UNIX. You need to tell it somewhere in the code that it is Windows not UNIX (using WIN32). The code may also have a makefile, in which case you can compile it directly, but you have to use Cygwin or MSYS.
I don't mean to make it sound like you can't learn to compile this code, it is just that it may be a lot more work then it is worth and beyond you abilities at the moment. You can use this as an incentive though. You have a lot to learn and on the day you successfully figure out how to compile this code you will know that you are no longer a novice programmer!
See Ya
Butch
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So famous I had to Google it to find out what it was! Even when you think we should know, include a link to where you got it from.
You probably don't have to "fix it" because it is unlikely to be broken. You are going to make life very hard for yourself if for each problem you draw the least likely diagnosis. Apply Occam's rasor - if hundreds of users happily use this tool, is it really likely on first use that you have discovered a bug rather than just misused the tool?
It is a command line tool; if you run it from Explorer, it will run, and when it has finished running, it will terminate and Windows will close its window for you. That is what all programs do, its normal behaviour, I wonder you have never noticed this. Those that are not designed to be interactive (primarily console mode apps, command line tools or batch utilities) won't wait around for you to observe the output.
Thanks everyone for your answers. In answer to Bradley:
No, I tried to run the hping2 from Windows Explorer by typing into the cmd: C:\Users[my computer name]\Desktop\hping2win32\hping.exe (this is the path on my computer) but the command prompt simply replied that this is not a valid command.
Can you tell me the exact command to use on the command prompt to run this executable?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The application in my folder is indeed hping without the 2. But it doesn't matter, because I tried cd and then the path with both hping.exe and hping2.exe, and what I was getting was always "the system cannot find the path specified." Why?????
What do you mean by "hostname" at the end of the path, by the way? I didn't include any hostname.
(Sorry for asking such dumb question.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> what I was getting was always "the system cannot
> find the path specified." Why?????
If "[my computer name]" contains spaces, you may need to enclose the path in quotes.
cd "C:\Users[my computer name]\Desktop\hping2win32"
If that fails, then I can assure you that it fails because the path does not exist - i.e. you've typed the wrong text. You could always copy and paste it from the explorer address bar to ensure it is accurate. I cannot tell you where your file is. You might try this one step at a time:
cd \Users
cd "[my computer name]"
cd Desktop
cd hping2win32
This will tell you which part of the path you have wrong. Then use the dir command to see what folders actually do exist.
> What do you mean by "hostname" at the end of the path,
> by the way? I didn't include any hostname.
There are two points I would make about this:
1) If you want to use command line tools, learn to use teh command line. Here http://commandwindows.com/ perhaps.
2) If you have no idea what hping is or how to use it, why are you interested?
I know nothing about hping2, but I can read documentation; I even posted a link to the documentation I read. Heve you read it? Go to that link, and you will see the command "hping2" followed by a long argument list. All argunemts in brakets, like [arg], are optional, anything else is compulsory. The only compulsory argument, right at the end is <hostname>.
If you don't understand what <hostname> is you probably have no good reason to be using hping2. However the following will at least do something, even if it is not very useful:
hping 127.0.0.1
127.0.0.1 is the TCP/IP network loopback address, it always refers to the local machine - i.e. you will be pinging yourself.
I just took a look at the Win32 download from http://www.hping.org/download.php where I assume you got this (I already mentioned that you should post a link, but you ignored that), and it is indeed hping.exe not hping2.exe (contrary to the documentation I linked). Did you also read the README.TXT file? It explains that hping2 only works on Ethernet networks. If you are connected to the internet via dial-up or via a USB device, you won't be able to use it for anything useful.
Anyway, this is not really a Dev-C++ or C/C++ programming issue, so I suggest that if you continue to have problems with this you try somewhere more appropriate. But first you need to learn how to operate a computer!
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, everyone.
Today I the dummy beginner programmer have this rather complex problem with which I need help.
I downloaded the famous hping2 tool, the executable together with its source code. Now as soon as I ran the executable on my windows vista I ran into the same problem again. The command console flashed on the screen for an instance and then quickly closed itself and disappeared.
So I decided to learn to recompile the source code as I know that many of you do. I wanted to learn to fix the source code so that the program can work on my vista. First of all I replaced the last line "return 0;" with "system("PAUSE"); return EXIT_SUCCESS;" in the main.c, thinking that that would fix the problem of the console immediately disappearing upon being opened. But as soon as I compiled the code a ton of compiler errors appeared. i was surprised: the author of the program is a famous expert, isn't he? I here give you the source code in main.c of this program (which contains like 50 or so other source files and header files) and the first half of the compile log showing the compiler errors.
/
* $smu-mark$
* $name: main.c$
* $author: Salvatore Sanfilippo <antirez@invece.org>$
* $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
* $license: This software is under GPL version 2 of license$
* $date: Fri Nov 5 11:55:48 MET 1999$
* $rev: 8$
/
/
* hping official page at http://www.kyuzz.org/antirez
* Covered by GPL version 2, Read the COPYING file for more information
/
/ $Id: main.c,v 1.26 2003/08/07 23:55:55 antirez Exp $ /
/
* Revised for Windows: Rob Turpin <rgturpin@epop3.com>
* 8/22/2004
/
include <string.h>
include <stdio.h>
include <stdlib.h>
include <signal.h>
include <time.h>
include <sys/types.h>
ifndef WIN32
include <sys/socket.h>
include <netinet/in.h>
include <arpa/inet.h>
include <sys/time.h>
include <unistd.h>
else
include <winsock2.h>
include <sys/timeb.h>
include <io.h>
endif
include "hping2.h"
if (!defined OSTYPE_LINUX) || (defined FORCE_LIBPCAP)
include <pcap.h>
endif / ! OSTYPE_LINUX || FORCE_LIBPCAP /
/ globals /
unsigned int
tcp_th_flags = 0,
linkhdr_size, / physical layer header size /
ip_tos = 0,
set_seqnum = FALSE,
tcp_seqnum = FALSE,
set_ack,
h_if_mtu,
virtual_mtu = DEFAULT_VIRTUAL_MTU,
ip_frag_offset = 0,
signlen,
lsr_length = 0,
ssr_length = 0,
tcp_ack;
unsigned short int
data_size = 0;
float
rtt_min = 0,
rtt_max = 0,
rtt_avg = 0;
int
sockpacket,
sockraw,
sent_pkt = 0,
recv_pkt = 0,
out_of_sequence_pkt = 0,
sending_wait = DEFAULT_SENDINGWAIT, / see DEFAULT_SENDINGWAIT /
opt_rawipmode = FALSE,
opt_icmpmode = FALSE,
opt_udpmode = FALSE,
opt_scanmode = FALSE,
opt_listenmode = FALSE,
opt_waitinusec = FALSE,
opt_numeric = FALSE,
opt_gethost = TRUE,
opt_quiet = FALSE,
opt_relid = FALSE,
opt_fragment = FALSE,
opt_df = FALSE,
opt_mf = FALSE,
opt_debug = FALSE,
opt_verbose = FALSE,
opt_winid_order = FALSE,
opt_keepstill = FALSE,
opt_datafromfile= FALSE,
opt_hexdump = FALSE,
opt_contdump = FALSE,
opt_sign = FALSE,
opt_safe = FALSE,
opt_end = FALSE,
opt_traceroute = FALSE,
opt_seqnum = FALSE,
opt_incdport = FALSE,
opt_force_incdport = FALSE,
opt_icmptype = DEFAULT_ICMP_TYPE,
opt_icmpcode = DEFAULT_ICMP_CODE,
opt_rroute = FALSE,
opt_tcpexitcode = FALSE,
opt_badcksum = FALSE,
opt_tr_keep_ttl = FALSE,
opt_tcp_timestamp = FALSE,
opt_tr_stop = FALSE,
opt_tr_no_rtt = FALSE,
opt_rand_dest = FALSE,
opt_rand_source = FALSE,
opt_lsrr = FALSE,
opt_ssrr = FALSE,
opt_cplt_rte = FALSE,
tcp_exitcode = 0,
src_ttl = DEFAULT_TTL,
src_id = -1, / random /
base_dst_port = DEFAULT_DPORT,
dst_port = DEFAULT_DPORT,
src_port = 0,
sequence = 0,
initsport = DEFAULT_INITSPORT,
src_winsize = DEFAULT_SRCWINSIZE,
src_thoff = (TCPHDR_SIZE >> 2),
count = DEFAULT_COUNT,
ctrlzbind = DEFAULT_BIND,
delaytable_index= 0,
eof_reached = FALSE,
icmp_ip_version = DEFAULT_ICMP_IP_VERSION,
icmp_ip_ihl = DEFAULT_ICMP_IP_IHL,
icmp_ip_tos = DEFAULT_ICMP_IP_TOS,
icmp_ip_tot_len = DEFAULT_ICMP_IP_TOT_LEN,
icmp_ip_id = DEFAULT_ICMP_IP_ID,
icmp_ip_protocol= DEFAULT_ICMP_IP_PROTOCOL,
icmp_ip_srcport = DEFAULT_DPORT,
icmp_ip_dstport = DEFAULT_DPORT,
opt_force_icmp = FALSE,
icmp_cksum = DEFAULT_ICMP_CKSUM,
raw_ip_protocol = DEFAULT_RAW_IP_PROTOCOL;
char
description [1024] = {'\0'},
datafilename [1024],
targetname [1024],
targetstraddr [1024],
ifname [1024] = {'\0'},
ifstraddr [1024],
spoofaddr [1024],
icmp_ip_srcip [1024],
icmp_ip_dstip [1024],
icmp_gwip [1024],
sign [1024],
rsign [1024], / reverse sign (hping -> gniph) /
ip_opt [40],
*opt_scanports = "";
unsigned char
lsr [255] = {0},
ssr [255] = {0};
unsigned
ip_optlen = 0;
struct sockaddr_in
icmp_ip_src,
icmp_ip_dst,
icmp_gw,
local,
remote;
ifndef WIN32
struct itimerval usec_delay;
else
struct timeb msec_delay;
endif
volatile struct delaytable_element delaytable[TABLESIZE];
struct hcmphdr hcmphdr_p; / global pointer used by send_hcmp to transfer
hcmp headers to data_handler */
if (!defined OSTYPE_LINUX) || (defined FORCE_LIBPCAP)
pcap_t *pcapfp;
char errbuf[PCAP_ERRBUF_SIZE];
struct pcap_pkthdr hdr;
endif / ! OSTYPE_LINUX || FORCE_LIBPCAP /
/ main /
int main(int argc, char **argv)
{
char setflags[1024] = {'\0'};
int c, hdr_size;
ifdef WIN32
WSADATA wsd;
HANDLE keyboard_handle = NULL;
endif
ifdef WIN32
// Load Winsock
if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) {
printf("WSAStartup() failed: %d\n", GetLastError());
return -1;
}
endif
/* reverse sign */
if (opt_sign || opt_listenmode) {
char src = sign+strlen(sign)-1; / last char before '\0' /
char dst = rsign;
}
/ get target address before interface processing /
if ((!opt_listenmode && !opt_safe) && !opt_rand_dest)
resolve((struct sockaddr*)&remote, targetname);
if (opt_rand_dest) {
strlcpy(targetstraddr, targetname, sizeof(targetstraddr));
}
else {
strlcpy(targetstraddr, inet_ntoa(remote.sin_addr), sizeof(targetstraddr));
}
/ get interface's name and address /
if ( get_if_name() == -1 ) {
printf("[main] no such device\n");
ifdef WIN32
endif
}
if (opt_verbose || opt_debug) {
printf("using %s, addr: %s, MTU: %d\n",
ifndef WIN32
else
endif
}
/ open raw socket /
sockraw = open_sockraw();
if (sockraw == -1) {
printf("[main] can't open raw socket\n");
ifdef WIN32
endif
}
/ set SO_BROADCAST option /
socket_broadcast(sockraw);
/ set SO_IPHDRINCL option /
socket_iphdrincl(sockraw);
/* open sock packet or libpcap socket */
if (defined OSTYPE_LINUX) && (!defined FORCE_LIBPCAP)
else
ifdef WIN32
endif
endif / OSTYPE_LINUX && !FORCE_LIBPCAP /
ifndef WIN32
/ use SIGALRM to send packets like ping do /
Signal(SIGALRM, send_packet);
/ binding /
if (ctrlzbind != BIND_NONE) Signal(SIGTSTP, inc_destparm);
Signal(SIGINT, print_statistics);
Signal(SIGTERM, print_statistics);
else
if (ctrlzbind != BIND_NONE) {
if ((keyboard_handle = GetStdHandle(STD_INPUT_HANDLE)) ==
INVALID_HANDLE_VALUE) {
fprintf(stderr, "GetStdHandle failed: %d\n" , GetLastError());
ctrlzbind = BIND_NONE;
}
}
signal(SIGINT, win_print_statistics);
signal(SIGTERM, win_print_statistics);
endif
else if (opt_icmpmode) {
strcat(setflags, "icmp mode");
hdr_size = IPHDR_SIZE + ICMPHDR_SIZE;
}
else if (opt_udpmode) {
strcat(setflags, "udp mode");
hdr_size = IPHDR_SIZE + UDPHDR_SIZE;
}
else {
if (tcp_th_flags & TH_RST) strcat(setflags, "R");
if (tcp_th_flags & TH_SYN) strcat(setflags, "S");
if (tcp_th_flags & TH_ACK) strcat(setflags, "A");
if (tcp_th_flags & TH_FIN) strcat(setflags, "F");
if (tcp_th_flags & TH_PUSH) strcat(setflags, "P");
if (tcp_th_flags & TH_URG) strcat(setflags, "U");
if (tcp_th_flags & TH_X) strcat(setflags, "X");
if (tcp_th_flags & TH_Y) strcat(setflags, "Y");
if (setflags[0] == '\0') strcat(setflags, "NO FLAGS are");
hdr_size = IPHDR_SIZE + TCPHDR_SIZE;
}
ifndef WIN32
else
endif
ifndef WIN32
/ start packet sending /
kill(getpid(), SIGALRM);
else
/
* Set a Windows timer to send packets. Replacement for signal SIGALRM under
* Unix.
/
/ if (opt_waitinusec == FALSE)
setTimer(send_packet, sending_wait * 1000, TIME_PERIODIC);
else
setTimer(send_packet, msec_delay.millitm, TIME_PERIODIC);/
initPeriod();
setTimer(send_packet, sending_wait * 10, TIME_ONESHOT);
endif
ifdef WIN32
endif
}
}
Now the first half of the compiler log:
compiler: default compiler
building makefile: "...\desktop\hping2win32\makefile.win"
executing make...
c:\dev-cpp\bin\make.exe -f "c:...\desktop\hping2win32\makefile.win" all
c:\dev-cpp\bin\gcc.exe -c main.c -o main.o -|"c:/dev-cpp/include" -Di386 -02
in file included from main.c:42
hping2.h:29:18:pcap.h:no such file or directory
in file included from hping2h:71
from main c:42
hcmp.h:20: error: syntax error before "u_int8_t"
hcmp.h:20: warning: no semicolon at end of struct or union
hcmp.h:23: erorr: syntax error before "u_int16_t"
hcmp:h:23: warning: no semicolon at end of struct or union
hcmp:h:24: warning: data definition has no type or storage class
hcmp:h:25: warning: data definition has no type or storage class
hcmp:h:26: error: syntax error before '}' token
in file included from main.c:42
hping2h:281: error syntax error before "u_int8_t"
hping2h:281: warning: no semicolon at end of struct or union
hping2h:289: warning: data definition has no type or storage class
hping2h:290: error: syntax error before "tot_len"
hping2h: 290: warning: data definition has no type or storage class
hping2h: 291: error: syntax error before "id"
hping2h: 291: warning: data definition has no type or storage class
hping2h: 292: error: syntax error before "frag_off"
hping2h: 292: warning: data definition has no type or storage class
hping2h: 293: error: syntax error before "ttl"
hping2h: 293: warning: data definition has no type or storage class
hping2h: 294: error: syntax error before "protocol"
hping2h: 294: warning: data definition has no type or storage class
hping2h: 295: error: syntax error before "check"
hping2h: 295: warning: data definition has no type or storage class
hping2h: 296: error: syntax error before "saddr"
hping2h: 296: warning: data definition has no type or storage class
hping2h: 297: error: syntax error before "daddr"
hping2h: 297: warning: data definition has no type or storage class
hping2h: 304: error: syntax error before "u_int16_t"
hping2h: 304: warning: no semicolon at end of struct or union
hping2h: 305: warning: data definition has no type or storage class
hping2h: 306: error: syntax error before "uh_ulen"
hping2h: 306: warning: data definition has no type or storage class
hping2h: 307: error: syntax error before "uh_sum"
hping2h: 307: warning: data definition has no type or storage class
hping2h: 315: error: syntax error before "u_int16_t"
hping2h: 315: warning: no semicolon at end of struct or union
hping2h: 316: warning: data definition has no type or storage class
hping2h: 317: error: syntax error before "th_seq"
hping2h: 317: warning: data definition has no type or storage class
hping2h: 318: error: syntax error before "th_ack"
hping2h: 318: warning: data definition has no type or storage class
hping2h: 320: error: syntax error before "th_x2"
hping2h: 328: warning: data definition has no type or storage class
hping2h: 329: error: syntax error before "th_win"
....................
The compiler log goes on and on without end, so I want to learn to fix the source codes little by little first. My very first problem is: it says that there is no pcap.h file or directory. Okay, I see that it's true that the whole hping2 source code does not contain a pcap.h. But I already have libpcap source code on my computer, so I just moved the pcap.h from libpcap folder to hping2 folder. But no use, the comiler still issues "pcap.h, no such file or directory." Now how to fix this problem?
The other questions will come later, please don't mind my super long question.
Will really appreciate someone's expert help.
Well you could try placing hping.exe in a simpler path. Are you sure you got the path right? How about the right command name!? The documentation clearly shows the command being "hping2" not "hping". And as I said, hping requires command line parameters, and you never gave it any in any case!
<Bangs head against wall repeatedly>
You should CD to it first, just to make life easier:
> cd C:\Users[my computer name]\Desktop\hping2win32
> hping2 <hostename>
Clifford
Hi everyone:
I'm going to do you a favor.
I don't have Vista (and don't plan on getting it anytime soon), so I'll have to wing this, someone else with Vista may be able to tell you exactly where to pull this up.
Find the "Run..." command, used to be in the start menu, but since Vista doesn't have a "Start", look in the round thing in the lower left. Enter either "cmd" or "command" (I don't know which one Vista accepts.) in the space provided and press the enter key.
The black console window will open and it will stay open until you close it. At the C:\ prompt enter the path to the executable program. You did not say what it is called, but I'm assuming it is called hping2.exe. That is, if hping2.exe is located directly on your C:\ drive enter at the prompt "hping2" (without the .exe suffix or the quotation marks). The program should run.
Since you are an admitted novice, compiling this code is probably something you should wait on until you know how to do it with simpiler code. Just by looking at the small bit you copied and pasted I can see that it was designed to be compiled for use by either Windows or UNIX. You need to tell it somewhere in the code that it is Windows not UNIX (using WIN32). The code may also have a makefile, in which case you can compile it directly, but you have to use Cygwin or MSYS.
I don't mean to make it sound like you can't learn to compile this code, it is just that it may be a lot more work then it is worth and beyond you abilities at the moment. You can use this as an incentive though. You have a lot to learn and on the day you successfully figure out how to compile this code you will know that you are no longer a novice programmer!
See Ya
Butch
So famous I had to Google it to find out what it was! Even when you think we should know, include a link to where you got it from.
You probably don't have to "fix it" because it is unlikely to be broken. You are going to make life very hard for yourself if for each problem you draw the least likely diagnosis. Apply Occam's rasor - if hundreds of users happily use this tool, is it really likely on first use that you have discovered a bug rather than just misused the tool?
It is a command line tool; if you run it from Explorer, it will run, and when it has finished running, it will terminate and Windows will close its window for you. That is what all programs do, its normal behaviour, I wonder you have never noticed this. Those that are not designed to be interactive (primarily console mode apps, command line tools or batch utilities) won't wait around for you to observe the output.
Besides that hping2 requires parameters to be passed to it. Look at the documentation: http://gd.tuwien.ac.at/www.hping.org/manpage.html It requires at least <hostname>.
Thanks everyone for your answers. In answer to Bradley:
No, I tried to run the hping2 from Windows Explorer by typing into the cmd: C:\Users[my computer name]\Desktop\hping2win32\hping.exe (this is the path on my computer) but the command prompt simply replied that this is not a valid command.
Can you tell me the exact command to use on the command prompt to run this executable?
Hello Clifford,
The application in my folder is indeed hping without the 2. But it doesn't matter, because I tried cd and then the path with both hping.exe and hping2.exe, and what I was getting was always "the system cannot find the path specified." Why?????
What do you mean by "hostname" at the end of the path, by the way? I didn't include any hostname.
(Sorry for asking such dumb question.)
> what I was getting was always "the system cannot
> find the path specified." Why?????
If "[my computer name]" contains spaces, you may need to enclose the path in quotes.
cd "C:\Users[my computer name]\Desktop\hping2win32"
If that fails, then I can assure you that it fails because the path does not exist - i.e. you've typed the wrong text. You could always copy and paste it from the explorer address bar to ensure it is accurate. I cannot tell you where your file is. You might try this one step at a time:
cd \Users
cd "[my computer name]"
cd Desktop
cd hping2win32
This will tell you which part of the path you have wrong. Then use the dir command to see what folders actually do exist.
> What do you mean by "hostname" at the end of the path,
> by the way? I didn't include any hostname.
There are two points I would make about this:
1) If you want to use command line tools, learn to use teh command line. Here http://commandwindows.com/ perhaps.
2) If you have no idea what hping is or how to use it, why are you interested?
I know nothing about hping2, but I can read documentation; I even posted a link to the documentation I read. Heve you read it? Go to that link, and you will see the command "hping2" followed by a long argument list. All argunemts in brakets, like [arg], are optional, anything else is compulsory. The only compulsory argument, right at the end is <hostname>.
If you don't understand what <hostname> is you probably have no good reason to be using hping2. However the following will at least do something, even if it is not very useful:
hping 127.0.0.1
127.0.0.1 is the TCP/IP network loopback address, it always refers to the local machine - i.e. you will be pinging yourself.
I just took a look at the Win32 download from http://www.hping.org/download.php where I assume you got this (I already mentioned that you should post a link, but you ignored that), and it is indeed hping.exe not hping2.exe (contrary to the documentation I linked). Did you also read the README.TXT file? It explains that hping2 only works on Ethernet networks. If you are connected to the internet via dial-up or via a USB device, you won't be able to use it for anything useful.
Anyway, this is not really a Dev-C++ or C/C++ programming issue, so I suggest that if you continue to have problems with this you try somewhere more appropriate. But first you need to learn how to operate a computer!
Clifford