| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import java.sql.*;
- import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
- /** Try common passwords against tenant sys_user.admin hash. */
- public class ProbeLoginTry {
- private static final String USER = "root";
- private static final String PWD = "Ylrz_1q2w3e4r5t6y";
- private static final String[] PASSWORDS = {
- "admin123", "123456", "Ylrz_1q2w3e4r5t6y", "1q2w3e4r", "ylrz123456",
- "Aa123456", "admin@123", "Admin123", "password", "111111"
- };
- public static void main(String[] args) throws Exception {
- Class.forName("com.mysql.cj.jdbc.Driver");
- BCryptPasswordEncoder enc = new BCryptPasswordEncoder();
- String[][] tenants = {
- {"test001", "ylrz_saas_tenant_1"},
- {"cs1", "fs_tenant_cs1"}
- };
- for (String[] t : tenants) {
- String jdbc = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/" + t[1]
- + "?useSSL=false&serverTimezone=GMT%2B8";
- try (Connection c = DriverManager.getConnection(jdbc, USER, PWD);
- Statement st = c.createStatement();
- ResultSet rs = st.executeQuery(
- "SELECT user_name, password FROM sys_user WHERE user_name='admin' AND del_flag='0' LIMIT 1")) {
- if (!rs.next()) {
- System.out.println(t[0] + ": no admin user");
- continue;
- }
- String hash = rs.getString("password");
- System.out.println("\n=== tenant " + t[0] + " (" + t[1] + ") ===");
- System.out.println("hash prefix: " + hash.substring(0, Math.min(29, hash.length())));
- boolean found = false;
- for (String pw : PASSWORDS) {
- if (enc.matches(pw, hash)) {
- System.out.println("MATCH password: " + pw);
- found = true;
- break;
- }
- }
- if (!found) {
- System.out.println("No match in common password list");
- }
- }
- }
- try (Connection c = DriverManager.getConnection(
- "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/ylrz_saas?useSSL=false&serverTimezone=GMT%2B8",
- USER, PWD);
- Statement st = c.createStatement()) {
- System.out.println("\n=== sys_config captcha (master) ===");
- try (ResultSet rs = st.executeQuery(
- "SELECT config_key, config_value FROM sys_config WHERE config_key LIKE '%captcha%'")) {
- while (rs.next()) {
- System.out.println(rs.getString(1) + " = " + rs.getString(2));
- }
- } catch (Exception e) {
- System.out.println("master sys_config: " + e.getMessage());
- }
- }
- for (String db : new String[]{"ylrz_saas_tenant_1", "fs_tenant_cs1"}) {
- String jdbc = "jdbc:mysql://cq-cdb-8fjmemkb.sql.tencentcdb.com:27220/" + db
- + "?useSSL=false&serverTimezone=GMT%2B8";
- try (Connection c = DriverManager.getConnection(jdbc, USER, PWD);
- Statement st = c.createStatement();
- ResultSet rs = st.executeQuery(
- "SELECT config_key, config_value FROM sys_config WHERE config_key LIKE '%captcha%'")) {
- System.out.println("\n=== sys_config captcha (" + db + ") ===");
- while (rs.next()) {
- System.out.println(rs.getString(1) + " = " + rs.getString(2));
- }
- } catch (Exception ignored) {
- }
- }
- }
- }
|