Write Scan Tool EG:

xiaoxiao2021-03-06  91

- "If the start port is equal to 1 * / stop_port = stop_port; / * If it is" - ", the end port is equal to 1 * /} if (start_port> stop_port) {/ * If the start port is greater than the end port * / printf ("Start Port./N"); USAGE (Argv [0]); exit (1);} if ((Host = gethostByname) == null) {/ * Use gethostByName () to get the other party's information * / printf ("can't get host info% s / n", argv [1]); exit (1);} printf ("scanning host% s from% D to% D ...................... / n ", argv [1], start_port, stop_port); for (i = start_port; i <= stop_port; i ) / * Use the for statement to connect to each port * / {if (Scan (i) == 0) {reply = getServByport (Htons (i), "tcp"); / * Get port information * / if ( Reply == NULL) / * Unable to get port information * / service = "uknown"; else service = reply-> s_name; / * reply-> s_name is port service * / printf ("Port% 5D is open. / tService < % s> / n ", i, service);} close (sock);}} / **************************************** ************************************************/ Look Do you understand the code above? If you don't understand, or write unsuccessful, use superscan, superscan scan results: * 209.249.191.73 | ___ 23 telnet | ___ ............ * 209.249.191.74 | ___ 23 Telnet * 209.249.191.75 | ___ 23 Telnet | ___ ...... # .. '* 209.249.191.76 | ___ 23 Telnet | ___ ...... # ..' * 209.249.191.77 | ___ 23 telnet * 209.249.191.78 | ___ 23 Telnet | ___ ...... # .. '* 209.249.202.166 | ___ 23 Telnet | ___ ...... # ..' * 209.249.202.167 | ___ 23 Telnet | ___ ...... # .. '* 209.249.202.168 | ___ 23 telnet | ___ ...... # ..' * 209.249.242.3 | ___ 23 telnet | ___ ... ......... * 209.249.242.14 | ___ 23 Telnet | ___ .............. user access: *

209.249.249.171 | ___ 23 Telnet | ___ ........ # .. '.. $ * 209.249.249.172 | ___ 23 telnet | ___ ........ # ..' .. Is it very annoying * and | ___ 23 telnet | ___ ........ # .. '.. What is, then write a program to get it, / ******** ***************** superscan clear.c ************************ / #include main (int Argc, char * argv []) {file * in; / * inputfile definition * / file * out; / * OutputFile definition * / char buf [1024]; / ​​* Buffer * / INT i, J; if (argc <3) {Printf ("USAGE:% s ", argv [0]); exit ();} in = fopen (Argv [1], "R"); / * Read file and error * / if (in == null) PUTS ("File Open Error"); OUT = FOPEN (Argv [2], "W"); / * Write files and check error * / if (out = = NULL) PUTS ("File Write Error"); While (FGETS (BUF, 21, IN)! = NULL) / * Input String * / {for (i = 0; I <18; I ) {IF (BUF [i] == '*') / * string replace * / {for (j = 0; j <17; j ) {buf [i j] = buf [i 4 j];} buf [i 17] = '/ n'; FPUTS (BUF, OUT); / * Writing * /}}} fclose (in); fclose (out);} / ************* *********************************************************** *********** / with TC to edit, you can achieve the best results. Use: c: /> Clear InputFile.txt outputfile.txt inputfile is a SuperScan scan knot The file OutputFile is the file to be generated after processing, and after generating the IP file Step 2 to return Banner through Telnet to determine the reverse system type. For example, C: /> Telnet 209.249.249.171 Sunos 5.8 login: thus judgment the opposite System type.

/ ************************************************** *********************************** / #include #include #include #include < Sys / types.h> #include #include #include #define port 23 / * Define port * / #define max 1024 / * buf length * / File * output; / * Define OutputFile * / Main (int Argc, char * argv []) {file * input; / * Define inputFile * / char scan_ip [1024]; if (argc <4) {usage (Argv [0]); exit (1);} if (argc == 4) {IF ((OUTPUT = FOPEN (Argv [2], "W")) == null) {/ * Create and write file * / Printf ("could not create the outputfile / n"); exit (2);} fputs ("/ n", output); if ((Input = FOPEN (Argv [1], "R") == Null) {/ * Read file * / printf ("could not read the inputfile / n"); exit (2);}} while (fscanf (input, "% s", & scan_ip)! = EOF) / * read IP * / {Telnet_banner (scan_ip, argv [3]); / * telnet_banner () judgment system type * /} exit (1);} int usage (char * pro) / * Help * / {printf ("System OS Detector V0. 1 / N "); Printf (" Welcome to www.9836.com / n "); Printf (" USAGE:% s / N ", Pro); Prin TF ("System OS 1. SUNOS 2. Redhat 3. FreeBSD / N");} Telnet_banner (Char * IP, Char * OS) {struct sockaddr_in addr; u_char buf [max]; int suck, size, i; IF (SOCK = Socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {Printf ("socket fails"); exit (1);} addr.sin_family = afd_inet; addr.sin_port = htons (port); addr.sin_addr .s_addr = inet_addr (ip); if (Connect (STRUCK, STRUCKADDR *) & addr, sizeof (addr)) == -1) {PrintF ("Connect Failt"); EXIT (1);} while (1) {/ * Receive Banner's loop * / MEMSET (BUF, 0, SIZEOF (BUF));

转载请注明原文地址:https://www.9cbs.com/read-122292.html

New Post(0)