메뉴 건너뛰기

조회 수 25545 추천 수 0 댓글 3
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

출처 :

http://stackoverflow.com/questions/1026483/is-there-a-way-to-crack-the-password-on-an-excel-vba-project/31005696#31005696

 

암호묻는 다이어로그 창의 리턴값을 1로 고정시켜서 암호를 맞게 입력한것으로 속이는 방법이다.

 

 

Excel 2007
Excel 2010
Excel 2013
Excel 2016

 

 

1. 락이걸린 엑셀파일을 연다.

2. 새 xlsm 파일을 생성한다.

3. Alt+F11 을 눌러 VBA를 실행한후 새로 만든 파일의 프로젝트를 선택하고 위의 메뉴의 Insert->Module 해서

   Module1 에 다음 코드를 복사해 넣는다 64bit 엑셀프로그램은 아래의 64bit 버전용 코드를 대신 삽입니다.

 

Excel 32bit 버전용 코드

 

Option Explicit

Private Const PAGE_EXECUTE_READWRITE = &H40

Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
        (Destination As Long, Source As Long, ByVal Length As Long)

Private Declare Function VirtualProtect Lib "kernel32" (lpAddress As Long, _
        ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long

Private Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As Long

Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _
        ByVal lpProcName As String) As Long

Private Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamA" (ByVal hInstance As Long, _
        ByVal pTemplateName As Long, ByVal hWndParent As Long, _
        ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer

Dim HookBytes(0 To 5) As Byte
Dim OriginBytes(0 To 5) As Byte
Dim pFunc As Long
Dim Flag As Boolean

Private Function GetPtr(ByVal Value As Long) As Long
    GetPtr = Value
End Function

Public Sub RecoverBytes()
    If Flag Then MoveMemory ByVal pFunc, ByVal VarPtr(OriginBytes(0)), 6
End Sub

Public Function Hook() As Boolean
    Dim TmpBytes(0 To 5) As Byte
    Dim p As Long
    Dim OriginProtect As Long

    Hook = False

    pFunc = GetProcAddress(GetModuleHandleA("user32.dll"), "DialogBoxParamA")


    If VirtualProtect(ByVal pFunc, 6, PAGE_EXECUTE_READWRITE, OriginProtect) <> 0 Then

        MoveMemory ByVal VarPtr(TmpBytes(0)), ByVal pFunc, 6
        If TmpBytes(0) <> &H68 Then

            MoveMemory ByVal VarPtr(OriginBytes(0)), ByVal pFunc, 6

            p = GetPtr(AddressOf MyDialogBoxParam)

            HookBytes(0) = &H68
            MoveMemory ByVal VarPtr(HookBytes(1)), ByVal VarPtr(p), 4
            HookBytes(5) = &HC3

            MoveMemory ByVal pFunc, ByVal VarPtr(HookBytes(0)), 6
            Flag = True
            Hook = True
        End If
    End If
End Function

Private Function MyDialogBoxParam(ByVal hInstance As Long, _
        ByVal pTemplateName As Long, ByVal hWndParent As Long, _
        ByVal lpDialogFunc As Long, ByVal dwInitParam As Long) As Integer
    If pTemplateName = 4070 Then
        MyDialogBoxParam = 1
    Else
        RecoverBytes
        MyDialogBoxParam = DialogBoxParam(hInstance, pTemplateName, _
                           hWndParent, lpDialogFunc, dwInitParam)
        Hook
    End If
End Function

 

64bit 버전 엑셀용 코드

 

Option Explicit

Private Const PAGE_EXECUTE_READWRITE = &H40

Private Declare PtrSafe Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As LongPtr, Source As LongPtr, ByVal Length As LongPtr)

Private Declare PtrSafe Function VirtualProtect Lib "kernel32" (lpAddress As LongPtr, _
ByVal dwSize As LongPtr, ByVal flNewProtect As LongPtr, lpflOldProtect As LongPtr) As LongPtr

Private Declare PtrSafe Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As LongPtr

Private Declare PtrSafe Function GetProcAddress Lib "kernel32" (ByVal hModule As LongPtr, _
ByVal lpProcName As String) As LongPtr

Private Declare PtrSafe Function DialogBoxParam Lib "user32" Alias "DialogBoxParamA" (ByVal hInstance As LongPtr, _
ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, _
ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer

Dim HookBytes(0 To 5) As Byte
Dim OriginBytes(0 To 5) As Byte
Dim pFunc As LongPtr
Dim Flag As Boolean

Private Function GetPtr(ByVal Value As LongPtr) As LongPtr
    GetPtr = Value
End Function

Public Sub RecoverBytes()
    If Flag Then MoveMemory ByVal pFunc, ByVal VarPtr(OriginBytes(0)), 6
End Sub

Public Function Hook() As Boolean
    Dim TmpBytes(0 To 5) As Byte
    Dim p As LongPtr
    Dim OriginProtect As LongPtr

    Hook = False

    pFunc = GetProcAddress(GetModuleHandleA("user32.dll"), "DialogBoxParamA")


    If VirtualProtect(ByVal pFunc, 6, PAGE_EXECUTE_READWRITE, OriginProtect) <> 0 Then

        MoveMemory ByVal VarPtr(TmpBytes(0)), ByVal pFunc, 6
        If TmpBytes(0) <> &H68 Then

            MoveMemory ByVal VarPtr(OriginBytes(0)), ByVal pFunc, 6

            p = GetPtr(AddressOf MyDialogBoxParam)

            HookBytes(0) = &H68
            MoveMemory ByVal VarPtr(HookBytes(1)), ByVal VarPtr(p), 4
            HookBytes(5) = &HC3

            MoveMemory ByVal pFunc, ByVal VarPtr(HookBytes(0)), 6
            Flag = True
            Hook = True
        End If
    End If
End Function

Private Function MyDialogBoxParam(ByVal hInstance As LongPtr, _
ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, _
ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer

    If pTemplateName = 4070 Then
        MyDialogBoxParam = 1
    Else
        RecoverBytes
        MyDialogBoxParam = DialogBoxParam(hInstance, pTemplateName, _
                   hWndParent, lpDialogFunc, dwInitParam)
        Hook
    End If
End Function

 

4. 같은방법으로 Insert->Module로 모듈생성후 Module2 에 다음코드를 복사한다

 

Sub unprotected()
    If Hook Then
        MsgBox "VBA Project is unprotected!", vbInformation, "*****"
    End If
End Sub

 

5. F5를 눌러 unprotected를 선택해 실행한다

 

6. 이제 암호걸렸던 VBA Project를 열어보면 더이상 암호를 묻지 않게된다. 도구의 프로젝트 속성에 가서 protected 모드를 해제하면 완벽히 제거된다.

 

 

  • ?
    dalongi 2016.10.02 23:48
    옹 뒤뒤 아재가 다시 게시판 활동하는 건가 ㅋㅋ
  • ?
    DDART 2017.09.08 00:03
    와우.. 회원가입해서 댓글 다는 사람이 다 있네.. 당신 스토커야? ㅋㅋ 아재라니... 말씀이 좀 지나치시군.. 다롱아재.
  • ?
    초보컴맹 2018.04.25 16:18
    안녕하세요. 위에 설명대로 했는데 엑셀파일 오류가 계속 걸릴는데 그럼 vba비번 풀수없는건가여?

  1. Fail2Ban 설정하기

    Date2019.06.11 ByDDART Views313588
    Read More
  2. 우분투 16.04 데스크탑 - CLI 모드로 전환 및 부팅하기

    Date2016.07.20 By관리자 Views38634
    Read More
  3. usb download tool - 32bit 운영체제에서 64bit 운영체제 usb 부팅디스크 만들기

    Date2013.08.07 ByDDART Views25659
    Read More
  4. VBA Project 패스워드 보호 제거하기

    Date2016.09.21 ByDDART Views25545
    Read More
  5. 저전력 홈서버 구축

    Date2013.10.17 ByDDART Views22979
    Read More
  6. MYSQL 덤프파일 입력

    Date2013.07.08 ByDDART Views22666
    Read More
  7. KimsQ RB IIS + PM 설치문제 해결

    Date2013.07.08 ByDDART Views22593
    Read More
  8. Ubuntu 12.04 Desktop 초기 설치

    Date2013.07.08 ByDDART Views22547
    Read More
  9. 갤럭시U 삭제가능한 기본어플

    Date2013.07.08 ByDDART Views22521
    Read More
  10. Ubuntu Mail Server 구축하기

    Date2013.07.08 ByDDART Views22481
    Read More
  11. 설치된 package 정보보기

    Date2013.07.08 ByDDART Views22180
    Read More
  12. Javascript reformatter

    Date2013.07.10 ByDDART Views22167
    Read More
  13. 메일서버 설정

    Date2013.07.08 ByDDART Views21698
    Read More
  14. 윈도우 메일서버구축

    Date2013.10.17 ByDDART Views21532
    Read More
  15. 우분투 파일시스템 이미지파일 만들기

    Date2013.07.08 ByDDART Views21465
    Read More
  16. 아파치2 rewrite mod enable

    Date2013.07.08 ByDDART Views21301
    Read More
  17. chrooted ubuntu 초기 설정

    Date2013.07.08 ByDDART Views21297
    Read More
  18. hMailServer 국가별 접속허용, 차단법

    Date2013.11.20 ByDDART Views21214
    Read More
  19. 작업순서

    Date2013.07.08 ByDDART Views21164
    Read More
  20. 갤럭시U 테그라크커널

    Date2013.07.08 ByDDART Views20788
    Read More
Board Pagination Prev 1 2 3 ... 4 Next
/ 4