Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- djangovscode
- 장고
- basic4
- 해킹문제
- 모세포
- 코로나바이러스
- 장고vscode
- 웹해킹
- 파이썬웹
- reversing
- csaw 2018
- rev-basic-3
- jango
- csaw
- 바이러스
- AndroidOS
- 파이썬
- rev-basic-6
- Django
- 코로나
- 해킹
- 취약점점검
- rev-basic-4
- web
- 백준
- 리버싱
- vscode
- webhacking.kr문제풀이
- 해커
- dreamhack
Archives
- Today
- Total
Kilkat
[powershell] 16진수 -> byte 문자열 본문
function Convert-HexStringToByteArray {
param ([string]$hexString)
$hexString = $hexString -replace "\\x", ""
if ($hexString.Length % 2 -ne 0) {
throw "16진수 문자열의 길이가 홀수입니다. 유효한 16진수 문자열이어야 합니다."
}
$bytes = @()
for ($i = 0; $i -lt $hexString.Length; $i += 2) {
$hexPair = $hexString.Substring($i, 2)
if ($hexPair -notmatch '^[0-9A-Fa-f]{2}$') {
throw "유효하지 않은 16진수 값: $hexPair"
}
$bytes += [byte]::Parse($hexPair, [System.Globalization.NumberStyles]::AllowHexSpecifier)
}
return ,$bytes
}
shell code 형태 변환을 위해 필요
ex
$shellcodeHex = "\x48\x83\xEC\x28\..."
function Convert-HexStringToByteArray {
param ([string]$hexString)
$hexString = $hexString -replace "\\x", ""
if ($hexString.Length % 2 -ne 0) {
throw "16진수 문자열의 길이가 홀수입니다. 유효한 16진수 문자열이어야 합니다."
}
$bytes = @()
for ($i = 0; $i -lt $hexString.Length; $i += 2) {
$hexPair = $hexString.Substring($i, 2)
if ($hexPair -notmatch '^[0-9A-Fa-f]{2}$') {
throw "유효하지 않은 16진수 값: $hexPair"
}
$bytes += [byte]::Parse($hexPair, [System.Globalization.NumberStyles]::AllowHexSpecifier)
}
return ,$bytes
}
$shellcodeBytes = Convert-HexStringToByteArray $shellcodeHex
$shellcodeBase64 = [Convert]::ToBase64String($shellcodeBytes)
Write-Output $shellcodeBase64
'Script > Windows' 카테고리의 다른 글
[powershell] shell_code.ps1 (0) | 2025.02.14 |
---|---|
[Windows] ms defender scheduling batch file (0) | 2024.03.15 |
Comments