-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHack.java
More file actions
25 lines (22 loc) · 753 Bytes
/
Hack.java
File metadata and controls
25 lines (22 loc) · 753 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
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.util.Scanner;
public class Hack {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a password: ");
String password = scanner.nextLine();
Connection con = DriverManager.getConnection("jdbc:sqlite:dont-panic.db");
String query = """
UPDATE "users"
SET "password" = ?
WHERE "username" = 'admin';
""";
PreparedStatement stmt = con.prepareStatement(query);
stmt.setString(1, password);
stmt.executeUpdate();
con.close();
scanner.close();
}
}