메뉴 건너뛰기

조회 수 25519 추천 수 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. 서버사이 동기화하기 - rsync, mariadb replication

    Date2020.07.07 ByDDART Views2528
    Read More
  2. msinfo 시스템정보 wmic cmd 명령

    Date2020.05.17 ByDDART Views3260
    Read More
  3. Visual Studio Code 에서 Autohotkey 설정

    Date2020.01.21 ByDDART Views3518
    Read More
  4. 우분투 19.04, 19.10, 20.04 으로 업그레이드 하기

    Date2019.12.21 ByDDART Views1577
    Read More
  5. 윈도우 10에서 구글 어시스턴트 명령

    Date2019.09.08 ByDDART Views2102
    Read More
  6. 해외 IP차단

    Date2019.06.12 ByDDART Views2465
    Read More
  7. Fail2Ban 설정하기

    Date2019.06.11 ByDDART Views313461
    Read More
  8. 윈도우 자동화관련 툴

    Date2019.06.01 ByDDART Views7185
    Read More
  9. PHP로 WOL Magic Packet 보내기

    Date2018.10.31 ByDDART Views14042
    Read More
  10. BATCH 문법

    Date2018.10.15 ByDDART Views3983
    Read More
  11. 우분투 16.04 에서 18.04 로 업그레이드하기

    Date2018.10.15 ByDDART Views1943
    Read More
  12. Windows 7, 8.1 에서 Windows 10으로 무료업그레이드하기

    Date2018.10.14 ByDDART Views4975
    Read More
  13. vsftpd 설정

    Date2017.12.11 ByDDART Views2103
    Read More
  14. crontab

    Date2017.09.08 ByDDART Views8358
    Read More
  15. VBA Project 패스워드 보호 제거하기

    Date2016.09.21 ByDDART Views25519
    Read More
  16. 우분투 16.04 ownCloud 9.1.0 설치

    Date2016.08.04 ByDDART Views5466
    Read More
  17. 우분투 16.04 Subversion - SVN서버, SVN+SSH 클라이언트

    Date2016.07.30 ByDDART Views10780
    Read More
  18. 우분투 16.04 FTP, Samba 등 가상디렉토리 추가

    Date2016.07.30 ByDDART Views3540
    Read More
  19. 우분투 16.04 MiniDLNA & BubbleUPnP Server 설치

    Date2016.07.29 ByDDART Views5538
    Read More
  20. 우분투 16.04 하드디스크 추가

    Date2016.07.28 ByDDART Views7236
    Read More
Board Pagination Prev 1 2 3 ... 4 Next
/ 4