Skip to content

Instantly share code, notes, and snippets.

@Aikhjarto
Created May 12, 2016 13:14
Show Gist options
  • Select an option

  • Save Aikhjarto/8bca2cb371b14abb8f15e237a9f513b0 to your computer and use it in GitHub Desktop.

Select an option

Save Aikhjarto/8bca2cb371b14abb8f15e237a9f513b0 to your computer and use it in GitHub Desktop.

Revisions

  1. Aikhjarto created this gist May 12, 2016.
    33 changes: 33 additions & 0 deletions Extract Bytes for Petya Key Searcher
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    #/bin/sh
    # extract bytes needed for decryption of Petya

    if [ -z $1 ]; then
    DEVPART=sdc
    else
    DEVPART=$1
    fi

    # extract sector 55
    dd if=/dev/${DEVPART} of=${DEVPART}_petya_sec_55_bytes.dd bs=512 count=1 skip=55

    # extract sector 54
    dd if=/dev/${DEVPART} of=${DEVPART}_petya_sec_54_bytes.dd bs=512 count=1 skip=54

    # extract 8 bytes from sector 54, starting from 33
    dd if=${DEVPART}_petya_sec_54_bytes.dd of=${DEVPART}_petya_nonce.dd bs=1 count=8 skip=33

    # concatenate sector 55 and nonce and form base64 encoded text file for website upload
    cat ${DEVPART}_petya_sec_55_bytes.dd | base64 > ${DEVPART}_petya_bytes_base64.txt
    cat ${DEVPART}_petya_nonce.dd | base64 > ${DEVPART}_petya_nonce_base64.txt

    # Method 1:
    # use base64 encoded textfiles on https://petya-pay-no-ransom.herokuapp.com/ to generate the key
    #
    # Method 2:
    # use https://github.com/leo-stone/hack-petya locally to generate the key
    # Steps to install (if you are not familiar with go):
    # mkdir go
    # cd go
    # export $GOPATH=$(pwd)
    # go get github.com/leo-stone/hack-petya
    #