Articles

Metasploit Framework Windows Tutorial
Remote Desktop Connection
Windows Processes That May Be Dangerous
How-To use NetCat a Tutorial
Common Linux Commands
Common Ports
Netcat Commands
HTTP Response Codes
War-Google Hack Terms
Wardriving
Avoiding Social Engineering and Phishing Attacks
Intrusion Detection on Linux
Linux Intrusion Detection
Penetration Testing Guide
Penetration Testing Tools
Social Engineering Fundamentals, Part I: Hacker Tactics
Social engineering (computer security)
The Psychology of Social Engineering

The Archives

General GSO
GovernmentSecurity.org News & Suggestions
In The News
Open Topic
General Security Information
Trash Can
Exploit & Vulnerability Mailing List Archives
Trial Member Forum
Product and Program Reviews GSO Tutorials
System Security
Windows Systems
Beginners Section
Linux & Unix Systems
File Downloads
Exploit Research & Discussion Trojan & Virus Errata
Networking Security / Firewall / IDS / VPN / Routers
System Hardening
E-Mail Security
Wifi Security
Trial Member Uploads
Upload discovered Trojans & Mal ware
GSO Programming Section
C , C++ , VC++
Visual Basic.NET
Perl /CGI
Java/Javascript
PHP/XML/ASP/HTML
Assembly + Other
The Cork Board
Network Security Consultant Directory
Network Security Jobs
The Archives
Encryption Information
General Network Security
Internet Anonymity
HTTP Protocol Security
Linux Security
MS IIS Information
Exploit Articles
Programming / Tool Design
GSO Software Projects
Public Downloads
Microsoft Security Questions and Papers

Full Version: Need A Bit Of Help
Rooble
Hi people, im starting out with C got myself lccwin32 - would like to really get me teeth into C ph34r.gif , urm, i was wondering, perhaps if someone could post a snippet of code, that would connect to an irc server and just keep the connection alive, nothing more, so from there on i could work on the code and what not? Although yes reading tutorials and books is probably the best way to go about it, i prefer learning hands on, so if anyone could help me out? or perhaps suggest a website that would contain such code id really appreciate it!! biggrin.gif
belgther
http://www.koders.com
http://www.google.com

Hope this helps...
Rooble
belgther thanks for your reply, but you need to understand my newbie status in C, so me hunting and hacking up code todo such a simple task will be a bit of a mystery for me.. I was hoping to find a single source file doing that one task, im sure that is possible? but ok ill keep searching, ill resume with google tongue.gif


Would i find it difficult as a newbie to get CPP code to work with C compiler?
Fractured
well certaintly if you google you will find many many c++ tutorials..

in my experience starting out, i would recomend you to use the Dev C++ compiler at http://www.bloodshed.net/
rather than the lcc one

It is very easy to use, just be careful that when you try to link something you know what you are doing, (ex:you have to add -l wsock32 to the compiler options) some people can get pretty confused about that.

in terms of finding code that only does that one thing, it will be pretty hard to find unless someone is writing a tutorial on that particular topic. the best bet would be to read the related RFCs and try to figure it out on your own. Going through other code is good too, once you know what you are looking for.
cowsonfire
take a look at 29a issue 7, there is a sample irc bot written in c
otcem
CODE
#include <winsock.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>

#define BUF 1024

int port = 6667;
char server[50] = "127.0.0.1";
char channel[20] = "#aaaa";
char chanpass[10] = "hehe";
char nick[10] = "toni32424";



void getdata(int irc);
void sendstr(char str[]);

SOCKADDR_IN remotehost;
SOCKET irc;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
char aux[60] = "";
   WSADATA wsaData;
   if (WSAStartup(MAKEWORD(2, 1), &wsaData) != 0)
 ExitProcess(0);

struct hostent *host = 0;

if ((host=gethostbyname(server)) == NULL)
 ExitProcess(0);

remotehost.sin_addr = *((struct in_addr *)host->h_addr);

remotehost.sin_family = AF_INET;
remotehost.sin_port = htons(port);
irc = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

if(connect(irc, (struct sockaddr *)&remotehost, sizeof(struct sockaddr))==SOCKET_ERROR)
  ExitProcess(0);

memset(aux, 0, sizeof(aux));
strcpy(aux,"NICK ");
strcat(aux, nick);
sendstr(aux);

strcpy(aux,"USER ");
strcat(aux, "guest la la :w t f");
sendstr(aux);
/*-----------*/

while (1)
 getdata(irc);
return 0;
}

void sendstr(char str[150])
{
strcat(str,"\n");
send(irc, str, strlen(str), 0);
}

void getdata(int irc)
{
char aux[512];
char aux2[512];
char *s[5];
int i;
int incdata;
char data[BUF];
if ((incdata=recv(irc, data, BUF-1, 0)) == -1)
 exit(0);


data[incdata] = '\0';

strncpy(aux2, data, sizeof(aux2)-1);
s[0] = strtok(data, " ");
for (i = 1; i < 5; i++) s[i] = strtok(NULL, " ");



if (strcmp("PING", s[0]) == 0)
 {
  sprintf(aux,"PONG %s\n",s[1]);
  sendstr(aux);
 }
else if (strcmp("376", s[1]) == 0)
 {
 strcpy(aux,"JOIN ");
 sendstr(strcat(aux, channel));
 }
}


Just found this on a "lost" folder... i'm not sure if it works...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.