Linux C语言写的超级简单端口扫描器
这个本来以前也写过的,今天无聊复习下 再写一遍。简单的一塌糊涂,写的不咋地大家见谅哦!有空再加强 嘿嘿!
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <time.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
void msg()
{
printf("EP:scan ip startport endport\nEP:scan ip 127.0.0.1 20 2009\n");
}
int main(int argc,char** argv)
{
char *ip;
int startport,endport,sockfd,i;
struct sockaddr_in to;
float costtime;
clock_t start,end;
if(4!=argc)
{
msg();
return 0;
}
ip=argv[1];
startport=atoi(argv[2]);
endport=atoi(argv[3]);
if(startport<1 || endport>65535 || endport<startport)
{
printf("端口范围出错\n");
return 0;
}
else
printf("IP:%s %d-%d\n",ip,startport,endport);
to.sin_family=AF_INET;
to.sin_addr.s_addr=inet_addr(ip);
start=clock();
for(i=startport;i<=endport;i++)
{
sockfd=socket(AF_INET,SOCK_STREAM,0);
to.sin_port=htons(i);
if(connect(sockfd,(struct sockaddr *)&to,sizeof(struct sockaddr))==0)
{
printf("%s %d\n",ip,i);
close(to);
}
}
end=clock();
costtime=(float)(end-start)/CLOCKS_PER_SEC;
printf("用时:%f秒\n",costtime);
return 0;
}
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
在上一篇文章中对线程进行了简单的概述,它在系统中和编程的应用中,扮演的角色是不言而喻的。学习它、掌握它、吃透它是作为一个程序员的必须作为。在接下来的讲述中,所有线程的操作都是用户级的操作。在LINUX中,一般pthread线程库是一套通用的线程库,是由POSIX提出的,因此他的移植性是非常好的。
& ......
本人前端时间写了个HTML文件分析器,windows平台上的VC6.0,使用标准C++。昨天接到指令,应要求要发布一个Linux版本的,茫然啦,Linux下面的hello world都没有玩过,对linux下的C++程序仅仅限于听他们神吹过的GCC, G++, MAKEFILE什么的,其他一概不知。这就注定移植过程必然full of frustrating.
早上在如同涓涓溪流 ......
Linux 下面使用RPC需要使用到命令rpcgen.
在Linux下开发RPC程序流程如下:
1.写一个rpc程序
如test.x
2.使用rpcgen生成必须的文件,通常是客户端和服务器端以及头文件
$rpcgen test.x
3.使用rpcgen生成服务器端和客户端的C语言代码
$rpcgen -Ss -o test_s ......
几个重要的Linux系统内核文件介绍
http://vod.sjtu.edu.cn/help/Article_Show.asp?ArticleID=2079
[ 作者:佚名 转贴自:天极网 点击数:3700 更新时间:2006-3-15 ]
mynix编译自www.linux.org之Linux HowTo之Kernel How ......