Programming
No. | 472 |
Name. | swindler |
Subject. | 제로보드 저장된 주민등록번호를 까보자 #1 |
Main Cate. | Java |
Sub Cate. | |
Date. | 2008-09-17 14:23 |
Hit. | 5043 (210.182.190.136) |
File. | |
제로보드에 보면 회원가입시 주민등록번호를 받는다. 중복가입방지를 위한 것으로 암호화되어 저장되기 때문에 관리자도 알수가 없다고 되어 있는데... 사실 암호화라는게 좀 그렇잖아. 보통 비밀번호같은 경우 원본을 알 필요는 없기 때문에 암호화를 해서 저장한다. 이것이 단방향이라 복호화는 되지 않는다. 따라서 암호를 풀어서 맞출수는 없지만 가능한 문자열을 암호화를 해서 비교를 해 보면 찾아낼수가 있다. (Dictionary Attack 이라고도 부른다.) 그래서 심심해서 한번 시작해봤다. 제로보드 소스를 보니까 mysql의 password 함수를 사용해서 저장한다. 일단 아래 데이터는 주민등록번호를 임의로 생성해서 (정확하진 않으나 대충) mysql password 를 해서 데이터 5만개를 임의로 만들어낸다. 마지막 자리는 사실 체크비트라서 앞자리 12자리가 정해지면 확정되는 값이나 귀찮아서 그냥 생성했다. 근데 나중에 해보고 알았는데, 저런것까지 다 신경쓰지 않으면 수행시간이 꽤 걸릴듯 하다. package net.coolx.test; import java.sql.Connection; import java.sql.PreparedStatement; import java.util.Random; import com.dnt7.common.DBConnection; import com.dnt7.common.Log; public class ZBPGenerate { public static void main(String [] args) { ZBPGenerate zbpTest = new ZBPGenerate(); zbpTest.generatePassword(); } // 주민등록번호를 임의 생성하여 암호화하여 DB에 저장 public void generatePassword() { Connection conn = null; PreparedStatement stmt = null; String query = null; String ssn = null; try { conn = DBConnection.getConnection(); query = "insert into zbtest(ssn, pssn) values(?, password(?))"; stmt = conn.prepareStatement(query); Log.print("start generate"); Log.printTime(); // N 개의 데이터 생성 for(int i=0; i<50000;i++) { ssn = ZBPGenerate.generateSSN(); if(i%1000==0) Log.print(""+i); stmt.setString(1, ssn); stmt.setString(2, ssn); stmt.executeUpdate(); } Log.print("end generate"); Log.printTime(); }catch(Exception e) { e.printStackTrace(); } finally { DBConnection.close(stmt); DBConnection.close(conn); } } public static String generateSSN() { Random r = new Random(); String ssn = ""; int n = 0; // 년도 2자리 생성 n = r.nextInt(99); ssn = ssn + (n<10 ? "0"+n : n); // 월 2자리 생성 n = r.nextInt(11)+1; ssn = ssn + (n<10 ? "0"+n : n); // 일 2자리 생성 n = r.nextInt(30)+1; ssn = ssn + (n<10 ? "0"+n : n); // 성별은 1,2,3,4만 사용 n = r.nextInt(3)+1; ssn = ssn + n; //2 n = r.nextInt(9); ssn = ssn + n; //3 n = r.nextInt(9); ssn = ssn + n; //4 n = r.nextInt(9); ssn = ssn + n; //5 n = r.nextInt(9); ssn = ssn + n; //6 n = r.nextInt(9); ssn = ssn + n; //7 (원래 패리티 비트이지만 귀찮으므로 그냥 생성) n = r.nextInt(9); ssn = ssn + n; return ssn; } } [바로가기 링크] : http://coolx.net/cboard/develop/472 |
|
|
|
[Modify] [Delete] | [Reply] [List] |