-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Covers everything except for flow, which is due for refactoring.
- Loading branch information
Showing
7 changed files
with
626 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pwny | ||
|
||
|
||
def setup(): | ||
pwny.target.assume(pwny.Target(arch=pwny.Architecture.x86)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from nose.tools import raises | ||
import pwny | ||
|
||
|
||
SOURCE = 'mov al, [0xced]' | ||
RESULT_BIN_32 = b'\xa0\xed\x0c\x00\x00' | ||
RESULT_BIN_64 = b'\x8a\x04%\xed\x0c\x00\x00' | ||
RESULT_ITH_32 = b':05000000A0ED0C000062\n:00000001FF\n' | ||
RESULT_ITH_64 = b':070000008A0425ED0C00004D\n:00000001FF\n' | ||
|
||
|
||
def test_asm(): | ||
if pwny.target.bits == 32: | ||
assert pwny.asm(SOURCE) == RESULT_BIN_32 | ||
else: | ||
assert pwny.asm(SOURCE) == RESULT_BIN_64 | ||
|
||
|
||
def test_asm_with_bits(): | ||
assert pwny.asm(SOURCE, bits=32) == RESULT_BIN_32 | ||
assert pwny.asm(SOURCE, bits=64) == RESULT_BIN_64 | ||
|
||
|
||
def test_asm_with_target(): | ||
target_32 = pwny.Target(arch=pwny.Architecture.x86) | ||
target_64 = pwny.Target(arch=pwny.Architecture.x86_64) | ||
assert pwny.asm(SOURCE, target=target_32) == RESULT_BIN_32 | ||
assert pwny.asm(SOURCE, target=target_64) == RESULT_BIN_64 | ||
|
||
|
||
def test_asm_with_bits_and_target(): | ||
target_32 = pwny.Target(arch=pwny.Architecture.x86) | ||
target_64 = pwny.Target(arch=pwny.Architecture.x86_64) | ||
assert pwny.asm(SOURCE, bits=32, target=target_64) == RESULT_BIN_32 | ||
assert pwny.asm(SOURCE, bits=64, target=target_32) == RESULT_BIN_64 | ||
|
||
|
||
def test_asm_with_format(): | ||
assert pwny.asm(SOURCE, fmt=pwny.asm.Format.ith, bits=32) == RESULT_ITH_32 | ||
assert pwny.asm(SOURCE, fmt=pwny.asm.Format.ith, bits=64) == RESULT_ITH_64 | ||
|
||
|
||
@raises(ValueError) | ||
def test_asm_invalid_format(): | ||
pwny.asm(SOURCE, fmt='ced') | ||
|
||
|
||
@raises(SyntaxError) | ||
def test_asm_syntax_error(): | ||
pwny.asm('mov ced, 3') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pwny | ||
|
||
|
||
def test_xor_int(): | ||
assert pwny.xor(61, b'fooo') == b'[RRR' | ||
|
||
|
||
def test_xor_str(): | ||
assert pwny.xor(b'abcd', b'fooo') == b'\x07\r\x0c\x0b' | ||
assert pwny.xor(b'abcd', b'fooofooo') == b'\x07\r\x0c\x0b\x07\r\x0c\x0b' | ||
|
||
|
||
def test_rot13(): | ||
assert pwny.rot13('whax') == 'junk' | ||
|
||
|
||
def test_caesar(): | ||
assert pwny.caesar(1, 'abcXYZ') == 'bcdYZA' | ||
|
||
|
||
def test_enhex(): | ||
assert pwny.enhex(b'ABCD') == '41424344' | ||
|
||
|
||
def test_dehex(): | ||
assert pwny.dehex('41424344') == b'ABCD' | ||
|
||
|
||
def test_enb64(): | ||
assert pwny.enb64(b'ABCD') == 'QUJDRA==' | ||
|
||
|
||
def test_deb64(): | ||
assert pwny.deb64('QUJDRA==') == b'ABCD' | ||
|
||
|
||
def test_frequency(): | ||
assert pwny.frequency('ABCD') == {'A': 1, 'B': 1, 'C': 1, 'D': 1} |
Oops, something went wrong.