Skip to content

Commit

Permalink
[ci] Increase coverage of commandline tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Arusekk authored and heapcrash committed Jun 21, 2020
1 parent c0202f9 commit e8b4f0b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -133,7 +133,7 @@ jobs:
pwn cyclic 32
pwn cyclic -l 0x62616161
pwn cyclic -a ab 16
pwn cyclic -a ab
echo
pwn shellcraft --list |tail
Expand Down
3 changes: 3 additions & 0 deletions pwnlib/commandline/asm.py
Expand Up @@ -5,6 +5,9 @@
import argparse
import sys

import pwnlib
pwnlib.args.free_form = False

from pwn import *
from pwnlib.commandline import common

Expand Down
11 changes: 6 additions & 5 deletions pwnlib/commandline/cyclic.py
Expand Up @@ -43,7 +43,7 @@
help = 'The os/architecture/endianness/bits the shellcode will run in (default: linux/i386), choose from: %s' % common.choices,
)

group = parser.add_mutually_exclusive_group(required = True)
group = parser.add_mutually_exclusive_group(required=False)
group.add_argument(
'-l', '-o', '--offset', '--lookup',
dest = 'lookup',
Expand All @@ -53,9 +53,10 @@

group.add_argument(
'count',
type = int,
nargs = '?',
help = 'Number of characters to print'
type=int,
nargs='?',
default=None,
help='Number of characters to print'
)

def main(args):
Expand Down Expand Up @@ -90,7 +91,7 @@ def main(args):
want = args.count
result = cyclic(want, alphabet, subsize)
got = len(result)
if got < want:
if want is not None and got < want:
log.failure("Alphabet too small (max length = %i)" % got)

out = getattr(sys.stdout, 'buffer', sys.stdout)
Expand Down
2 changes: 1 addition & 1 deletion pwnlib/commandline/errno.py
Expand Up @@ -45,4 +45,4 @@ def main(args):
print(os.strerror(value))

if __name__ == '__main__':
pwnlib.commandline.common.main(__file__)
common.main(__file__)
2 changes: 1 addition & 1 deletion pwnlib/commandline/hex.py
Expand Up @@ -26,4 +26,4 @@ def main(args):
print(enhex(data))

if __name__ == '__main__':
pwnlib.commandline.common.main(__file__)
common.main(__file__)
8 changes: 4 additions & 4 deletions pwnlib/commandline/phd.py
Expand Up @@ -85,12 +85,12 @@ def main(args):
text.when = color

if skip:
if infile == sys.stdin:
infile.read(skip)
else:
try:
infile.seek(skip, os.SEEK_CUR)
except IOError:
infile.read(skip)

if count:
if count != -1:
infile = io.BytesIO(infile.read(count))

hl = []
Expand Down
2 changes: 1 addition & 1 deletion pwnlib/commandline/unhex.py
Expand Up @@ -30,4 +30,4 @@ def main(args):
sys.stderr.write(str(e) + '\n')

if __name__ == '__main__':
pwnlib.commandline.common.main(__file__)
common.main(__file__)

0 comments on commit e8b4f0b

Please sign in to comment.