|
代码如下:
- package com.tc;
- import java.io.BufferedReader;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.PrintWriter;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import java.net.URLConnection;
- public class C段获取响应 {
- public static void main(String[] args) throws Exception {
- System.out.println("网站内网C段扫描工具------有问题请加企鹅:ceo@tom.com");
- BufferedReader strin1=new BufferedReader(new InputStreamReader(System.in));
- System.out.println("请输入内网网段:(例:http://www.baidu.com/nei.jsp?http://10.0.0.)");
- String url = strin1.readLine();
- BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));
- System.out.println("请输入端口:");
- String port = strin.readLine();
-
- for (int i = 0; i <=255; i++) {
- getconn(url+i+":"+port);
- }
-
- System.out.println("扫描结束------有问题请加企鹅:ceo@tom.com");
-
- }
- public static void getconn(String surl){
- try {
- URL url = new URL(surl);
- URLConnection rulConnection = url.openConnection();
- HttpURLConnection httpUrlConnection = (HttpURLConnection) rulConnection;
- httpUrlConnection.setConnectTimeout(300);
- httpUrlConnection.setReadTimeout(300);
- httpUrlConnection.connect();
- String code = new Integer(httpUrlConnection.getResponseCode()).toString();
- String message = httpUrlConnection.getResponseMessage();
- // System.out.println( code);
- if(!code.startsWith("2")){
- throw new Exception("ResponseCode is not begin with 2,code="+code);
- }
- String ipurl=surl.split("http://")[1].toString();
- System.out.println(surl+"--------"+code);
- xier(surl);
- }catch(Exception ex){
- System.out.println(surl+" "+"无法访问");
- }
- }
-
- public static void xier(String str) throws Exception{
- PrintWriter pw2 = null;
- FileOutputStream fos2 = new FileOutputStream(System.getProperty("user.dir")+"\\success.txt", true);
- System.out.println(System.getProperty("user.dir"));
- pw2 = new PrintWriter(fos2);
- pw2.println(str);
- pw2.close();
- }
- }
复制代码
封装好的jar下载地址:
链接:http://share.weiyun.com/437584a9e9474c33df8c158085783bf9 (密码:tZLx)
工具预览:
[/url]
[url=http://static.wooyun.org/upload/image/201508/2015081411452190523.png]
|
|