Follow us on Twitter!
It is the path of least resistance that makes rivers and men crooked. - Bj Palmer
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 25
Guests Online: 25
Members Online: 0

Registered Members: 82905
Newest Member: BLckLIght
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-05-06 22:31
Right. Here we are.

I've been working on this bot for about an hour, and I can't for the life of me work out how to get it to respond to PINGs.

Anyone who can get it to do that will get my undying respect.

Code

*include <iostream>
*include <string>
*include <sys/types.h>
*include <sys/socket.h>
*include <netinet/in.h>
*include <arpa/inet.h>

using namespace std;

class connection
{
    public:
    connection(int sock=0):sockfd(sock)
    {}
    int connecting()
    {
        target.sin_family = AF_INET;
        target.sin_addr.s_addr = inet_addr("193.138.229.11");
        target.sin_port = htons(6667);
        memset(&(target.sin_zero), '&*92;0', 8);
        testcon = connect(sockfd, (struct sockaddr *)&target, sizeof(struct sockaddr));
        if(testcon != 0)
        {
            cout << "Unable to establish connection to server" << endl;
        }
        else
        {
            cout << "Connection established" << endl;
        }     
        return testcon;
    }
    void joinroom()
    {
    a = 0;
        get = -1;
        while(1)
        {
            get = recv(sockfd, buf, 8192, 0);
            cout << buf;
            if(a == 1)
            {
                send(sockfd, "USER BobbyBot 8 * :BobbyBot&*92;r&*92;n", 30, 0);
                cout << "Sent User" << endl;
                a++;
            }
            if(a == 0)
            {
                send(sockfd, "NICK BobbyBot&*92;r&*92;n", 16, 0);
                cout << "Sent Nick" << endl;
                a++;
            }
            if (strstr(buf, "PING") != 0)
            {
                buf[1] = 79;
                ponged = send(sockfd, buf, strlen(buf), 0);
                cout << buf;
                cout << ponged << endl;
            }
            memset (buf, '&*92;0', 8192);
        }
    }         
    ~connection()
    {}
    private:
    int a, testcon, get, sockfd, ponged;
    struct sockaddr_in target;
    char buf[8192];
};
     
int main()
{
    int connected;
    connection * con = new connection(socket(PF_INET, SOCK_STREAM, 0));
    if(con->connecting() != 0)
    {
        return -1;
    }
    con->joinroom();
    return 0;
}




For some reason, the hashes came out as asterisks, but you get the gist.




Edited by on 25-05-06 22:36
Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-05-06 23:13
no, "but I just saved a bunch of money on my car insurance using Geico."


Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-05-06 23:18
Wtf kinda post was that? And ill look for you bro.


Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-05-06 23:25
Why C++?


Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 25-05-06 23:44
to my humble opinion using JAVA or Python to make IRC bots are the best languages to use.


Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 26-05-06 00:06
DONT REPLY IF YOU HAVE NOTHING CONSTRUCTIVE TO SAY MORONS


Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 26-05-06 00:13
It's more to do with my unjustified disdain for interpreted languages. C++/C is just THAT much faster, and it's the language I've been programming in for ages.

The most annoying part is that I've done this before with no difficulty, but I'm tired and I'm making some stupid mistake.

DOn't worry guys, I'll feel more awake inn the morning and I'll sort this out.




Edited by on 26-05-06 00:13
Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 26-05-06 07:03
Willeh I'm sorry if my post did not educate you in any way. But I do not feel that EVERY SINGLE post in this forum has to be useful or "CONSTRUCTIVE" in your eyes some people (like myself) did not know what the advantages of coding the IRC bot in C++ were over PHP or Perl. So if you think I am a "MORON" for asking a simple question, I really wonder what your definition of a moron actually is.Sad


Author

RE: C++ IRC bot


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 26-05-06 07:05
Oh and BobbyB I hope you manage to get it to respond to PINGs.
Good Luck.