Last active
February 21, 2018 04:53
-
-
Save zqu4rtz/b1b7596820bd87a5597584dc6d8b86a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple powershell script to extract keys from usb keyboard pcap. | |
# | |
# first, extract payloads or keys from pcap file: tshark -r file.pcap -T fields -e usb.capdata -w D:\Data.txt | |
# then run script | |
$dataClean = get-content D:\Data.txt | |
$al = @{"04"="a";"05"="b";"06"="c";"07"="d";"08"="e";"09"="f";"0a"="g";"0b"="h";"0c"="i";"0d"="j";"0e"="k";"0f"="l";"10"="m";"11"="n";"12"="o";"13"="p";"14"="q";"15"="r";"16"="s";"17"="t";"18"="u";"19"="v | |
";"1a"="w";"1b"="x";"1c"="y";"1d"="z";"1e"="1";"1f"="2";"20"="3";"21"="4";"22"="5";"23"="6";"24"="7";"25"="8";"26"="9";"27"="0";"28"="\n";"2b"="\t";"2c"=" ";"2d"="-";"2e"="=";"2f"="[";"30"="]";"37"=".";"38"="/";"11e"="!";"11f"="@";"120"= | |
"#";"121"="$";"122"="%";"123"="^";"124"="*";"125"="(";"126"=")";"12d"="_";"12f"="{";"130"="}";"50"="izq";"4f"="der";"34"="'"}; | |
$index = 0; | |
$result = ""; | |
$dataClean | % { | |
$arr=$_.split(':'); | |
if($al.Get_Item($arr[2]) -ne $null){ | |
if($arr[0] -eq "02" -and [Char]::IsLetter($al.Get_Item($arr[2]))){ | |
$result = $result.Insert($index, $al.Get_Item($arr[2]).ToUpper()); | |
$index++; | |
} elseif($arr[0] -eq "02" -and -not [Char]::IsLetter($al.Get_Item($arr[2]))){ | |
$result = $result.Insert($index, $al.Get_Item("1"+$arr[2])); | |
$index++; | |
} elseif($arr[2] -eq "50"){ | |
$index--; | |
} elseif($arr[2] -eq "4f"){ | |
$index++; | |
} else{ | |
$result = $result.Insert($index, $al.Get_Item($arr[2])); | |
$index++; | |
} | |
} | |
} | |
$result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment