passi
hi!
i got a nice banner grabber but with linux source code!
could anyone transform the code for windows and compile it?
this would be great biggrin.gif

thanks a lot!
passiw

--------------------------------------------------------------------------------------







/*
* Sil v1.0 Tiny banner grabber by sacrine©
* http://www.netric.org // sacrine@netric.org
* irc.netric.org // #netric
*
* Greets: all members of Netric, my girlfriend wink.gif
* Mon Apr 29 00:49:06 2002
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main(int argc, char *argv[])
{
char grab[911];
int port,sock;
struct hostent *aap;
struct sockaddr_in addr;

if(argc<2) { fprintf(stderr,"%s <host> <port>\n",argv[0]);
exit(1); }
if(argc>2) { port=atoi(argv[2]); }
if((aap=(struct hostent *)gethostbyname(argv[1]))==NULL) {
perror("gethostbyname()");
exit(1); }
if((sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0) {
perror("socket()");
exit(1); } addr.sin_family=AF_INET;
addr.sin_port=htons(port);

memcpy((char *)&addr.sin_addr,(char *)aap->h_addr,aap->h_length);
if(connect(sock,(struct sockaddr *)&addr,sizeof(addr))!=0) {
perror("connect()");
exit(0); } fflush(stdin);
read(sock,&grab,910);
printf("%s",grab);
return(0);
}
Hexboy
I wrote something that does the same exact thing , windows source code will be up soon. you do know you could just connect with telnet and probably get the same results..

MAh site
shaun2k2
I've ported it to Windows for you...

CODE

/*
* Sil v1.0 Tiny banner grabber by sacrineİ
* http://www.netric.org // sacrine@netric.org
* irc.netric.org // #netric
*
* Greets: all members of Netric, my girlfriend;)
* Mon Apr 29 00:49:06 2002
*
* Ported to Windows by Shaun2k2 - shaunige@yahoo.co.uk
* http://www.nettwerked.co.uk
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock.h>  /* The Windows Winsock header file */

int main(int argc, char *argv[])
{
char grab[911];
int port,sock;
struct hostent *aap;
struct sockaddr_in addr;

/* Windows specific code */
WSADATA wsaData;
if(WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
printf("Error - Couldn't initialise Winsock!\n");
exit(-1);
}
/* Windows specific code ends here */

if(argc<2) { fprintf(stderr,"%s <host> <port>\n",argv[0]);
exit(1); }
if(argc>2) { port=atoi(argv[2]); }
if((aap=(struct hostent *)gethostbyname(argv[1]))==NULL) {
perror("gethostbyname()");
exit(1); }
if((sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP))<0) {
perror("socket()");
exit(1); } addr.sin_family=AF_INET;
addr.sin_port=htons(port);

memcpy((char *)&addr.sin_addr,(char *)aap->h_addr,aap->h_length);
if(connect(sock,(struct sockaddr *)&addr,sizeof(addr))!=0) {
perror("connect()");
exit(0); } fflush(stdin);
read(sock,&grab,910);
closesocket(sock);
WSACleanup();
printf("%s",grab);
return(0);
}

I haven't tested this because I do not have access to a Windows system, I have just ported this program using what knowledge I have regarding the Winsock library. You can easily compile it yourself, please don't tell me you can't man.

http://www.borland.com
http://www.bloodshed.net/

Simple download one of these compilers and copy and paste the code.


Thank you for your time.
Shaun.
passi
a BIG BIG BIG BIG BIG BIG BIG BIG BIG Thanks to you guys! GREAT HELP!!! biggrin.gif
shaun2k2
You're welcome. smile.gif
Did the code compile?


-Shaun.
Hexboy
SOrry to bring up yet another crusty thread, but why didn't he use telnet? Just curious, heh. also, my site is now HERE if anyone gave two cents about my code.
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.