All pastes #606659 Raw Edit

Anonymous

public c v1 · immutable
·published 2007-07-07 00:24 UTC
rendered paste body
// Scan 1.0 (C)// Coded by Anonymous// A simple port scanner in C#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <netdb.h>#include <unistd.h>int main(){        char host[42];        int start_port, end_port, i;        printf("[ Scan 1.0 by Anonymous ]\n");        printf("\n");        printf("[+] Host: ");        scanf("%s", &host);        printf("[+] Start port: ");        scanf("%d", &start_port);        printf("[+] End port: ");        scanf("%d", &end_port);        printf("\n");        // The scanning engine        for (i = start_port; i <= end_port; i++)        {                struct sockaddr_in addr;                struct hostent *ip;                int sockfd = socket(PF_INET, SOCK_STREAM, 0);                ip = gethostbyname(host);                addr.sin_family = AF_INET;                addr.sin_port = htons(i);                addr.sin_addr.s_addr = inet_addr(ip);                if ((connect(sockfd, &addr, sizeof(addr))) >= 0)                {                        printf("[*] Port %d is open.\n", i);                        close(sockfd);                }        }        return 0;}