Author Topic: Question: Port Scanner and IRC botnet  (Read 1705 times)

0 Members and 1 Guest are viewing this topic.

Offline Clone

  • Peasant
  • *
  • Posts: 50
  • Cookies: 2
  • Always trying to find the value of x
    • View Profile
Question: Port Scanner and IRC botnet
« on: March 09, 2014, 11:32:39 am »
I have tried the port scanner out but it doesn't seem to work ,I thought it was the AV but nah! its my first time dealing with  winsock socket programming and I might say windows based progarmming is like math classes  >:( ... so many functions,structs,data types  aaaah! but thats not for today  :-X ......here is my code:
Code: (C++) [Select]

#include <iostream>
#include <winsock2.h>
#pragma comment(lib,"ws2_32.lib")
 
char TargetIp[256];
unsigned int Start_P,End_P,Current_P;
 
int main()
{
    std::cout<<"\t\tPort Scanner\t\t\n";
    std::cout<<"\t\t-------------\t\t\n";
    std::cout<<"Enter target IP address:";
    std::cin>>TargetIp;
    std::cout<<"Enter start port:";
    std::cin>>Start_P;
    std::cout<<"Enter End port:";
    std::cin>>End_P;
    if(Start_P<End_P)
    {
    std::cout<<"Error:Start port needs to be less than End port.\n";
    exit(0);
    }
    else{
 
 
    // Initialise Winsock
    WSADATA WsaDat;
    if(WSAStartup(MAKEWORD(2,2),&WsaDat)!=0)
    {
        std::cout<<"Winsock error - Winsock initialization failed\r\n";
        WSACleanup();
        system("PAUSE");
        return 0;
    }
     
    // Create our socket
    SOCKET Socket=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    if(Socket==INVALID_SOCKET)
    {
        std::cout<<"Winsock error - Socket creation Failed!\r\n";
        WSACleanup();
        system("PAUSE");
        return 0;
    }
 
    // Resolve IP address for hostname
    struct hostent *host;
    if((host=gethostbyname(TargetIp))==NULL)
    {
        std::cout<<"Failed to resolve hostname.\r\n";
        WSACleanup();
        system("PAUSE");
        return 0;
    }
 
    // Setup our socket address structure
    SOCKADDR_IN SockAddr;
    SockAddr.sin_port=htons(8888);
    SockAddr.sin_family=AF_INET;
    SockAddr.sin_addr.s_addr=*((unsigned long*)host->h_addr);
    for(Current_P=Start_P;Current_P<=End_P;Current_P++)
    {
 
    // Attempt to connect to server
    if(connect(Socket,(SOCKADDR*)(&SockAddr),sizeof(SockAddr))!=0)
    {
        std::cout<<"Failed to establish connection with server at port "<<Current_P<<"\n";
        WSACleanup();
        system("PAUSE");
        return 0;
    }
 
    else
    {
        std::cout<<"Port:"<<Current_P<<"is OPEN"<<std::endl;
    }
    }
    // Shutdown our socket
    shutdown(Socket,SD_BOTH);
 
    // Close our socket entirely
    closesocket(Socket);
 
    // Cleanup Winsock
    WSACleanup();
    }
    system("PAUSE");
    return 0;
}

In addition to that ,I was learning about botnets so that I at least help out my fellow botnet noobs but got errors.
The code is from the youtube video by julian search it ...I only tried to clone it and understand its structure but it seems i need expert advice  :-\ on botnets coding for windows.NB: Ez admins don't take the bot target address serious i wasn't try to cause harm.Its just an example.
Code...

Code: (C) [Select]
#pragma comment(lib,"Ws2_32.lib")
#include<Winsock2.h>
#include<Windows.h>
 
SOCKET cSock;//socket 
HOSTENT*host;//structure to deal with server address
SOCKADDR_IN addr;//structure for server address.
char IP[128]={0};
char pingnumber[128]={0};
char pinganswer[17]="PONG:";
 
 
//the bot won't have an interface it will be an empty application
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR CmdLine, int CMDShow)
{
    //first we startup winsock
    WSAData wsaData;
    if(WSAStartup(MAKEWORD(2,2), &wsaData)!=0) //*WSAStartup(MAKEWORD(2,2) it returns 
           exit(0);                          // a value of non-zero if there is a problem
                                            //we exit the application*
                                           //exit(0);
     
    host=gethostbyname("Irc.evilzone.org");//look up ip address.changes form human understandable to
                                          // ip address 192.168.0.234.
                                         //Ez admins don't take the address serious i wasn't try to cause harm.Its just an example   
    memcpy(IP,inet_ntoa(*(in_addr*)host->h_addr_list[0]),128);//inet_ntoa() converts ip to char.
     
    //fill out socket address instruction.
    addr.sin_addr.s_addr=inet_addr(IP);
    addr.sin_family=AF_INET;
    addr.sin_port=htons(6667);
    //create socket.
    cSock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);//use TCP protocol.
     
    if(connect(cSocket,(SOCKADDR*)&addr,sizeof(addr))==SOCKET_ERROR)//check if connect returns zero if so exit program.
                  exit(01;
        send(cSocket,"User custom 0,0 Bro\r\n",strlen("USER custom 0 0 Bro\r\n"),NULL));//send user command consisting of client name and user name.
                                                                                              //client name is used to establish the connection.
                                                                                              //give the bot a name....I choose Death.
                                                                                              //the escape characters /r /n are for showing we are sending complete commands.             
        send(CSocket,"Nick Bro\r\n",strlen("Nick Bro\r\n"),NULL);
        for(;//infinte loop that keeps receving data.
        {
            memset(buffer,0,256);//there is need to clean recv buffer before we recv new message.
             
            recv(cSock,buffer,sizeof(buffer),NULL);
            //PING :1234567890 servers send ping requests with huge numbers
            //PONG:1234567890 you reply the same way.
             
             
            //we need to find out if a ping request is sent.
            for(int c=0; c!= strlen(buffer);c++)
            {
                if((buffer[c]=='P') && (buffer[c+1]=='I') && (buffer[c+2]=='N') &&(buffer[c+3]=='G'))
                {
                //if it is sent we need to reply the same number by extracting the number.
                    memset(pingnumber,0,128);
                    memcpy(pingnumber,buffer+c+6,10);
                    memcpy(pinganswer+6,pingnumber,10);
                    memcpy(pinganswer+16,"\r\n",strlen("\r\n"));
                    //we check if the ping number was extracted well.
                    MessageBoxA(NULL,pinganswer,NULL,NULL);
                    send(cSock,pinganswer,strlen(pinganswer),NULL);
                }
            }
        }
return 0;
}

I would appreciate it if any one would point me to a good beginners guide to c c++ win32 programming :D
« Last Edit: March 09, 2014, 11:45:32 am by Clone »
One who walks the line between light and dark, with no ties to either side. No morals or emotions clouding their judgment,able to accomplish tasks and solve problems in the most efficient and logical way.

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Question: Port Scanner and IRC botnet
« Reply #1 on: March 09, 2014, 01:37:24 pm »

Z3R0

  • Guest
Re: Question: Port Scanner and IRC botnet
« Reply #2 on: March 09, 2014, 04:02:51 pm »
The bot is incomplete, it doesn't complete the IRC PING/PONG challenge. Not only that, even if you did reply, your bot would stop working because it doesn't PONG for every PING it receives. Not to mention, it doesn't join a channel, and has no functionality programmed in it to interact with the channel.


Try to take this as constructive criticism, but...your skills are not developed enough to take on a project such as this. Continue learning to program, and understand how computers work in general. I know you're eager to learn how to get these working, but come back to them when you know more.
« Last Edit: March 09, 2014, 04:06:20 pm by m0rph »

Offline Clone

  • Peasant
  • *
  • Posts: 50
  • Cookies: 2
  • Always trying to find the value of x
    • View Profile
Re: Question: Port Scanner and IRC botnet
« Reply #3 on: March 09, 2014, 04:30:05 pm »
Try to take this as constructive criticism, but...your skills are not developed enough to take on a project such as this. Continue learning to program, and understand how computers work in general. I know you're eager to learn how to get these working, but come back to them when you know more.

True enough but the guyz here don't help at lot its always go do more.....work harder..... but maybe a pointer to source or a reference to sample codes or a tut or whatever the likes would be
 a bit better.

Try this one: https://evilzone.org/c-c/c-tutorial/
Thanks chief!  :)

Code: [Select]
int  Ez gurus=100%;
int  Clone=0%;

while(Clone<=Ez gurus)
{
Clone+=Ez gurus;
}

I must really suck at programming to be given this tut...https://evilzone.org/c-c/c-tutorial/   :'( well I guess I am not like you guyz who begun programming at 10yrs old....I need to take some time off Ez and work hard maybe come back later on in life. It was fun though sure learnt lot though. :)

Staff note: no double posting pl0x!
« Last Edit: March 09, 2014, 06:43:01 pm by Kulverstukas »
One who walks the line between light and dark, with no ties to either side. No morals or emotions clouding their judgment,able to accomplish tasks and solve problems in the most efficient and logical way.

Offline BossHacker0101

  • /dev/null
  • *
  • Posts: 16
  • Cookies: -4
  • Max
    • View Profile
Re: Question: Port Scanner and IRC botnet
« Reply #4 on: April 01, 2014, 09:21:51 pm »

I must really suck at programming to be given this tut...https://evilzone.org/c-c/c-tutorial/   :'( well I guess I am not like you guyz who begun programming at 10yrs old....I need to take some time off Ez and work hard maybe come back later on in life. It was fun though sure learnt lot though. :)


If that's what you want. But i think you can also learn while being a bit active on EZ. That is what i do. Just keep the learning going and then sometimes take a look on EZ and comment on some post. You don't have to be very active all the time. But if you want to come back in a year that's also fine.