用c写了个后台扫描
/**
* Notice: The program is not debug on internet and not use thread supervene.
* date : 6-26
* author: jker
**/
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#define LINE 1024
#define dict "dict.txt"
#define result "manager.txt" void itos(int num,char *str){
int a=num;
int x,y,z;
x=a/;
y=a%/;
z=a%;
if(x==){
if(y==){
str[]+=z;
str[]='\0';
}else{
str[]+=y;
str[]+=z;
str[]='\0';
}
}else{
str[]+=x;
str[]+=y;
str[]+=z;
str[]='\0';
}
return;
}
char *nip(char *oip){
char *str[]={""},*rtn;
char *delim = ".";
char * tmp;
int i=;
char arr[]={,,,'\0'};
rtn = malloc();
memset(rtn,'\0',);
tmp = strtok(oip,delim);
str[i++]=tmp;
while(tmp=strtok(NULL,delim)){
str[i++]=tmp;
} for(i=;i>=;i--){
if(atoi(str[i])<){
itos(atoi(str[i])+,arr);
str[i]=arr;
break;
}
} for(i=;i<;i++){
strcat(rtn,str[i]);
if(i<)strcat(rtn,delim);
} return rtn;
}
int main(int argc,char *argv[]){
int sc,fd;
unsigned short port = ;
struct sockaddr_in add;
char *ip,*sip,*eip;
struct hostent *host;
char rheader[LINE],dictbuf[LINE],resbuf[LINE];
char *dir,path[LINE]="",*arr[LINE],*tmp,state[],manager[LINE];
int i=,n=,bytes;
if(argc != ){
printf("please input startIp and endIp.\r\n");
return -;
}
dir = get_current_dir_name();
strcat(path,dir);
strcat(path,"/");
strcat(path,dict);
fd = open(path,O_RDONLY);
read(fd,dictbuf,sizeof(dictbuf));
close(fd);
arr[n++]=strtok(dictbuf,"\r\n");
while(tmp=strtok(NULL,"\r\n"))arr[n++]=tmp; ip = malloc();
memset(ip,'\0',);
sip = argv[];
eip = argv[];
strcpy(ip,sip); memset(manager,'\0',LINE);
memset(rheader,'\0',LINE); sc = socket(AF_INET,SOCK_STREAM,);
if(sc == -){
printf("create socket fail!\r\n");
return -;
}
printf("create socket ok.\r\n");
bzero(&add,sizeof(add));
add.sin_family=AF_INET;
add.sin_port=htons(port);
bzero(&path,sizeof(path));
strcat(path,dir);
strcat(path,"/");
strcat(path,result);
fd = open(path,O_WRONLY|O_CREAT); do{
host = gethostbyaddr(ip,strlen(ip),AF_INET);
if(host == (struct hostent *)NULL) {
printf("can`t get host from %s\r\n",ip);
if(strcmp(ip,eip)<)ip=nip(ip);
continue;
}else{
printf("host name:%s\n",host->h_name);
} add.sin_addr.s_addr=inet_addr(ip);
if(connect(sc,(struct sockaddr *)(&add),sizeof(struct sockaddr))==-){
printf("conn fail!\r\n");
return -;
}
for(;i<n;i++){
strcat(rheader,"HEAD ");
strcat(rheader,arr[i]);
strcat(rheader," HTTP/1.1");
strcat(rheader,"\r\n");
strcat(rheader,"Host:");
strcat(rheader,host->h_name);
strcat(rheader,"\r\n"); //strcat(rheader,"Accept:*\/*");
//strcat(rheader,"\r\n");
strcat(rheader,"Connection:Keep-Alive");
strcat(rheader,"\r\n");
write(sc, rheader, strlen(rheader));usleep();
bytes = read(sc, resbuf, LINE);
printf("Response from %s:\n",ip);
write(STDOUT_FILENO, resbuf, bytes);
for(i=;i<;i++){
state[i]=resbuf[i+];
}
if(!((state>="" && state<="")||state=="")){
strcat(manager,"http://");
strcat(manager,host->h_name);
strcat(manager,arr[i]);
strcat(manager,"\r\n");
write(fd,manager,sizeof(manager));
}
}
close(sc);
ip = nip(ip);
}while(strcmp(ip,eip)<); close(fd);
return ;
}
用c写了个后台扫描的更多相关文章
- Python 网站后台扫描脚本
Python 网站后台扫描脚本 #!/usr/bin/python #coding=utf-8 import sys import urllib import time url = "ht ...
- 网站后台扫描工具dirbuster、御剑的用法
dirbuster DirBuster是Owasp(Open Web Application Security Project )开发的一款专门用于探测网站目录和文件(包括隐藏文件)的工具.由于使用J ...
- Python 网站后台扫描
title date layout tags Python 网站后台扫描 2018-05-08 post Python #!/usr/bin/python # This was written for ...
- Vue2.0 + ElementUI 手写权限管理系统后台模板(一)——简述
挤一下: 一开始以为没有多少人用就没建群,但是加我的人太多了,好多问题都是重复的,所以建个群大家互相沟通交流方便点,但是建的有点晚,错过了好多人所以群里人有点少,QQ群: 157216616 小提示 ...
- python 写的http后台弱口令爆破工具
今天来弄一个后台破解的Python小程序,哈哈,直接上代码吧,都有注释~~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...
- [开源]如何使用goapp写你的后台管理系统_golang
简析 基于 Gin + GORM + Casbin + vue-element-admin 实现的权限管理系统. 基于Casbin 实现RBAC权限管理. 前端实现: vue-element-admi ...
- c#写一个网站后台扫描器
主要分成了那么几个步骤: 1.HTTP状态码 2.字典的导入 3.显示在listview控件当中 第一步: 先来实现HTTP状态码200的判断 try { req = (HttpWebRequest) ...
- 第一个Asp.net小项目,主页写了下后台代码
一个比较完善的登录模块,就目前的知识范围来说应该算是完美的. 涉及到:cookies,Session,验证码等知识面 Cookies存放一组值: HttpCookie cook = new HttpC ...
- vue elementui 写的一个后台管理页面模板
https://github.com/PanJiaChen/vue-element-admin
随机推荐
- Centos6.6系统root用户密码恢复案例(转)
原文:http://www.centoscn.com/CentOS/Intermediate/2015/0131/4604.html 通过单用户模式恢复root用户密码 重新启动主机后,在出现Grub ...
- weblogic.servlet.proxy.HttpProxyServlet 进行代理设置
1:代理访问服务器应用配置 A:192.168.0.11 B:192.168.0.12 访问:http://192.168.0.11:9001/test/test.jsp 代理服务直接代理访问: ht ...
- Java总结:Java 流(Stream)、文件(File)和IO
更新时间:2018-1-7 12:27:21 更多请查看在线文集:http://android.52fhy.com/java/index.html java.io 包几乎包含了所有操作输入.输出需要的 ...
- POSIX 线程详解
一种支持内存共享的简捷工具 POSIX(可移植操作系统接口)线程是提高代码响应和性能的有力手段.在本系列中,Daniel Robbins 向您精确地展示在编程中如何使用线程.其中还涉及大量幕后细节,读 ...
- 用Navicat Premium 操作MySQL数据库
1. 用Navicat来查看MySQL数据库 打开Navicat Premium–>[连接]–>[MySQL]–>[连接名:新建数据库的名字,此处为“本地”]:[主机: ...
- hadoop的namenode无法启动的解决的方法
安装hadoop集群时,启动集群,发现master节点的namenode没有启动成功.这一般都是没有格式格式化namenode的缘故.格式化一下就可以,格式化namenode的命令:在hadoop安装 ...
- NGINX原理 之 SLAB分配机制(转)
1 引言 众所周知,操作系统使用伙伴系统管理内存,不仅会造成大量的内存碎片,同时处理效率也较低下.SLAB是一种内存管理机制,其拥有较高的处理效率,同时也有效的避免内存碎片的产生,其核心思想是预分配. ...
- 代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧
近期接触了几个刚入门的iOS学习者,他们之中存在一个普遍和困惑和疑问.就是应该怎样制作UI界面.iOS应用是非常重视用户体验的,能够说绝大多数的应用成功与否与交互设计以及UI是否美丽易用有着非常大的关 ...
- 国内四大炒股软件APP 全面技术解析
随着人们的焦点逐步由电脑PC端转为手机端之后,国内炒股软件也逐步开始推出手机炒股APP,但是面对如此众多的都以“最牛.最佳”等冠名的APP真的实至名归吗?为了大家不再走弯路,不沉迷智能选股,笔者将近期 ...
- '<>' operator is not allowed for source level below 1.7
报错:'<>' operator is not allowed for source level below 1.7 这是eclipse的编译环境与项目的要求不对应造成的,这个错误一般是导 ...