功能: 代理访问虽然是个简单的功能,但是我觉得够用了。完全可以用来直接扫描内网其他web服务器的目录,尝试内网其其他登陆入口的弱口令,或者直接代理打struts或者其他漏洞。
web扫描: 其实我觉得用web发现更加贴切,其实有了端口扫描为啥还要这个.(因为之前的代码不想动它了。)
端口扫描: 大家都懂。(此功能问题较多,我觉得如果能使用工具或者代理回来就尽量不使用此脚本进行扫描。)
list = new ArrayList (); String referer = ""; String cookie = ""; String decode = "utf-8"; int thread = 100; //final static List scanportlist = new ArrayList (); String cpath=""; //建立一个HTTP连接 HttpURLConnection getHTTPConn(String urlString) { try { java.net.URL url = new java.net.URL(urlString); java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url .openConnection(); conn.setRequestMethod("GET"); conn.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon;)"); conn.addRequestProperty("Accept-Encoding", "gzip"); conn.addRequestProperty("referer", referer); conn.addRequestProperty("cookie", cookie); //conn.setInstanceFollowRedirects(false); conn.setConnectTimeout(3000); conn.setReadTimeout(3000); return conn; } catch (Exception e) { return null; } } String PostData(String urlString, String postString) { HttpURLConnection http = null; String response = null; try { java.net.URL url = new java.net.URL(urlString); http = (HttpURLConnection) url.openConnection(); http.setDoInput(true); http.setDoOutput(true); http.setUseCaches(false); http.setConnectTimeout(50000); http.setReadTimeout(50000); http.setRequestMethod("POST"); http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); http.connect(); OutputStreamWriter osw = new OutputStreamWriter( http.getOutputStream(), decode); osw.write(postString); osw.flush(); osw.close(); response = getHtmlByInputStream(http.getInputStream(), decode); } catch (Exception e) { response = getHtmlByInputStream(http.getErrorStream(), decode); } return response; } HttpURLConnection conn; //从输入流中读取源码 String getHtmlByInputStream(java.io.InputStream is, String code) { StringBuffer html = new StringBuffer(); try { java.io.InputStreamReader isr = new java.io.InputStreamReader(is, code); java.io.BufferedReader br = new java.io.BufferedReader(isr); String temp; while ((temp = br.readLine()) != null) { if (!temp.trim().equals("")) { html.append(temp).append("\n"); } } br.close(); isr.close(); } catch (Exception e) { System.out.print(e.getMessage()); } return html.toString(); } //获取HTML源码 String getHtmlContext(HttpURLConnection conn, String decode,boolean isError) { Map result = new HashMap (); String code = "utf-8"; if (decode != null) { code = decode; } try { return getHtmlByInputStream(conn.getInputStream(), code); } catch (Exception e) { try { if(isError){ return getHtmlByInputStream(conn.getErrorStream(), code); } } catch (Exception e1) { System.out.println("getHtmlContext2:" + e.getMessage()); } System.out.println("getHtmlContext:" + e.getMessage()); return "null"; } } //获取Server头 String getServerType(HttpURLConnection conn) { try { return conn.getHeaderField("Server"); } catch (Exception e) { return "null"; } } //匹配标题 String getTitle(String htmlSource) { try { List list = new ArrayList (); String title = ""; Pattern pa = Pattern测试数据pile(" .*? "); Matcher ma = pa.matcher(htmlSource); while (ma.find()) { list.add(ma.group()); } for (int i = 0; i ", ""); } catch (Exception e) { return null; } } //得到css List getCss(String html, String url, String decode) { List cssurl = new ArrayList (); List csscode = new ArrayList (); try { String title = ""; Pattern pa = Pattern测试数据pile(".*href=\"(.*)[.]css"); Matcher ma = pa.matcher(html.toLowerCase()); while (ma.find()) { cssurl.add(ma.group(1) + ".css"); } for (int i = 0; i " + getHtmlContext(getHTTPConn(cssuuu), decode,false) + " "; csscode.add(csshtml); } } catch (Exception e) { System.out.println("getCss:" + e.getMessage()); } return csscode; } //域名解析成IP String getMyIPLocal() throws IOException { InetAddress ia = InetAddress.getLocalHost(); return ia.getHostAddress(); } boolean getHostPort(String task){ Socket client = null; boolean isOpen=false; try{ String[] s=task.split(":"); client = new Socket(s[0], Integer.parseInt(s[1])); isOpen=true; System.out.println("getHostPort:"+task); //scanportlist.add(task+" >>> Open"); saveScanReslt2(task+" >>> Open\r\n"); }catch(Exception e){ isOpen=false; } return isOpen; } void getPath(String path){ cpath=path; } /* void saveScanReslt(String s){ try{ FileUtils.writeStringToFile(new File(cpath+"/port.txt"), s,"UTF-8",true); }catch(Exception e){ System.out.print(e.getLocalizedMessage()); } } */ void saveScanReslt2(String content) { FileWriter writer = null; try { writer = new FileWriter(cpath+"/port.txt", true); writer.write(content); } catch (IOException e) { System.out.print(e.getLocalizedMessage()); } finally { try { if(writer != null){ writer.close(); } } catch (IOException e) { System.out.print(e.getLocalizedMessage()); } } } String s="Result: "; String readPortResult(String portfile){ File file = new File(portfile); BufferedReader reader = null; try { System.out.println(""); reader = new BufferedReader(new FileReader(file)); String tempString = null; while ((tempString = reader.readLine()) != null) { s+=tempString+" "; } reader.close(); } catch (IOException e) { return null; } finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { return null; } } } return s; } %> 内网简单扫描脚本 function showDiv(obj) { //var statu = document.getElementById("prequest").style.display; if (obj == "proxy") { document.getElementById("proxy").style.display = "block"; document.getElementById("web").style.display = "none"; document.getElementById("port").style.display = "none"; } else if (obj == "web") { document.getElementById("proxy").style.display = "none"; document.getElementById("web").style.display = "block"; document.getElementById("port").style.display = "none"; } else if (obj == "port") { document.getElementById("proxy").style.display = "none"; document.getElementById("web").style.display = "none"; document.getElementById("port").style.display = "block"; } }代理访问 Web扫描 端口扫描
查看更多关于内网探测脚本(内网代理访问+内网端口扫描)[php+jsp]_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did114581