Skip to content

Commit ddb5798

Browse files
committed
Merge branch 'stable' into beta
2 parents f227796 + f1624dc commit ddb5798

File tree

11 files changed

+50
-31
lines changed

11 files changed

+50
-31
lines changed

.github/workflows/changelog.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ jobs:
1717

1818
- name: Check changelog for updates
1919
run: |
20-
git log --stat ${GITHUB_BASE}..HEAD | grep CHANGELOG.md
20+
if git log --stat ${GITHUB_BASE}..HEAD | grep CHANGELOG.md; then
21+
echo 'Changelog updated :D'
22+
else
23+
if git log --stat ${GITHUB_BASE}..HEAD | grep '++\|--'; then
24+
echo 'Major changes detected, changelog required!'
25+
false
26+
else
27+
echo 'Minor changes detected, no changelog required!'
28+
fi
29+
fi

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Continuous Integration
22
on: [push, pull_request]
33

44
jobs:
5-
build:
5+
test:
66
strategy:
77
matrix:
88
python-version: [2.7, 3.8]
@@ -194,7 +194,7 @@ jobs:
194194
staging-merge:
195195
runs-on: ubuntu-latest
196196
if: github.repository_owner == 'Gallopsled' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/heads/') && endsWith(github.event.ref, '-staging')
197-
needs: build
197+
needs: test
198198
steps:
199199
- uses: actions/checkout@v2
200200
with:
@@ -212,7 +212,7 @@ jobs:
212212
pypi:
213213
runs-on: ubuntu-latest
214214
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
215-
needs: build
215+
needs: test
216216
steps:
217217
- name: Download artifacts
218218
uses: actions/download-artifact@v2

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Lint
22
on: [push, pull_request]
33

44
jobs:
5-
build:
5+
lint:
66
strategy:
77
matrix:
88
python-version: [3.8]

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ The table below shows which release corresponds to each branch, and what date th
106106
## 4.2.1 (`stable`)
107107

108108
- [#1625][1625] GDB now properly loads executables with QEMU
109+
- [#1663][1663] Change lookup algorithm of `adb.which`
110+
- [#1699][1699] Fix broken linux shellcraft templates
109111

110112
[1625]: https://github.com/Gallopsled/pwntools/pull/1625
113+
[1699]: https://github.com/Gallopsled/pwntools/pull/1699
111114

112115
## 4.2.0
113116

pwnlib/adb/adb.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,10 +827,12 @@ def which(name, all = False, *a, **kw):
827827
"""
828828
# Unfortunately, there is no native 'which' on many phones.
829829
which_cmd = '''
830-
echo $PATH | while read -d: directory; do
831-
[ -x "$directory/{name}" ] || continue;
832-
echo -n "$directory/{name}\\x00";
833-
done
830+
(IFS=:
831+
for directory in $PATH; do
832+
[ -x "$directory/{name}" ] || continue;
833+
echo -n "$directory/{name}\\x00";
834+
done
835+
)
834836
[ -x "{name}" ] && echo -n "$PWD/{name}\\x00"
835837
'''.format(name=name)
836838

pwnlib/elf/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def __init__(self, name, title, requires=[], excludes=[], minver=0, maxver=99):
2121
self.excludes = set(excludes)
2222

2323
#: Kernel version that this check should be enforced on
24-
self.minver = map(int, str(minver).split('.'))
25-
self.maxver = map(int, str(maxver).split('.'))
24+
self.minver = list(map(int, str(minver).split('.')))
25+
self.maxver = list(map(int, str(maxver).split('.')))
2626

2727
def relevant(self, config):
2828

pwnlib/elf/elf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def __init__(self, path, checksec=True):
319319
config = gz.read()
320320

321321
if config:
322-
self.config = parse_kconfig(config)
322+
self.config = parse_kconfig(config.decode())
323323

324324
#: ``True`` if the ELF is a statically linked executable
325325
self.statically_linked = bool(self.elftype == 'EXEC' and self.load_addr)
@@ -1055,7 +1055,10 @@ def _populate_kernel_version(self):
10551055
return
10561056

10571057
banner = self.string(self.symbols.linux_banner)
1058-
1058+
1059+
# convert banner into a utf-8 string since re.search does not accept bytes anymore
1060+
banner = banner.decode('utf-8')
1061+
10591062
# 'Linux version 3.18.31-gd0846ecc
10601063
regex = r'Linux version (\S+)'
10611064
match = re.search(regex, banner)

pwnlib/rop/rop.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,15 +1129,15 @@ def __load(self):
11291129
#
11301130
# - leave
11311131
# - pop reg
1132-
# - add $sp, value
1132+
# - add $sp, <hexadecimal value>
11331133
# - ret
11341134
#
11351135
# Currently, ROPgadget does not detect multi-byte "C2" ret.
11361136
# https://github.com/JonathanSalwan/ROPgadget/issues/53
11371137
#
11381138

11391139
pop = re.compile(r'^pop (.{3})')
1140-
add = re.compile(r'^add [er]sp, (\S+)$')
1140+
add = re.compile(r'^add [er]sp, ((?:0[xX])?[0-9a-fA-F]+)$')
11411141
ret = re.compile(r'^ret$')
11421142
leave = re.compile(r'^leave$')
11431143
int80 = re.compile(r'int +0x80')
@@ -1153,6 +1153,8 @@ def __load(self):
11531153
# False
11541154
# >>> valid('add esp, 0x24')
11551155
# True
1156+
# >>> valid('add esp, esi')
1157+
# False
11561158
#
11571159
valid = lambda insn: any(map(lambda pattern: pattern.match(insn), [pop,add,ret,leave,int80,syscall,sysenter]))
11581160

pwnlib/shellcraft/templates/i386/linux/acceptloop_ipv4.asm

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ ${acceptloop}:
2020
/* Socket file descriptor is placed in EBP */
2121

2222
/* sock = socket(AF_INET, SOCK_STREAM, 0) */
23-
${i386.linux.push(0)}
24-
${i386.linux.push('SOCK_STREAM')}
25-
${i386.linux.push('AF_INET')}
23+
${i386.push(0)}
24+
${i386.push('SOCK_STREAM')}
25+
${i386.push('AF_INET')}
2626
${i386.linux.syscall('SYS_socketcall', 'SYS_socketcall_socket', 'esp')}
2727

28-
${i386.linux.mov('esi', 'eax')} /* keep socket fd */
28+
${i386.mov('esi', 'eax')} /* keep socket fd */
2929

3030
/* bind(sock, &addr, sizeof addr); // sizeof addr == 0x10 */
31-
${i386.linux.push(0)}
31+
${i386.push(0)}
3232
/* ${htons(port)} == htons(${port}) */
33-
${i386.linux.push('AF_INET | (%d << 16)' % htons(port))}
34-
${i386.linux.mov('ecx', 'esp')}
33+
${i386.push('AF_INET | (%d << 16)' % htons(port))}
34+
${i386.mov('ecx', 'esp')}
3535

36-
${i386.linux.push(0x10)} /* sizeof addr */
37-
${i386.linux.push('ecx')} /* &addr */
38-
${i386.linux.push('eax')} /* sock */
36+
${i386.push(0x10)} /* sizeof addr */
37+
${i386.push('ecx')} /* &addr */
38+
${i386.push('eax')} /* sock */
3939
${i386.linux.syscall('SYS_socketcall', 'SYS_socketcall_bind', 'esp')}
4040

4141
/* listen(sock, whatever) */
@@ -44,17 +44,17 @@ ${acceptloop}:
4444

4545
${looplabel}:
4646
/* accept(sock, NULL, NULL) */
47-
${i386.linux.push(0x0)}
48-
${i386.linux.push('esi')} /* sock */
47+
${i386.push(0x0)}
48+
${i386.push('esi')} /* sock */
4949
${i386.linux.syscall('SYS_socketcall', 'SYS_socketcall_accept', 'esp')}
5050

51-
${i386.linux.mov('ebp', 'eax')} /* keep in-coming socket fd */
51+
${i386.mov('ebp', 'eax')} /* keep in-coming socket fd */
5252

5353
${i386.linux.syscall('SYS_fork')}
5454
xchg eax, edi
5555

5656
test edi, edi
57-
${i386.linux.mov('ebx', 'ebp')}
57+
${i386.mov('ebx', 'ebp')}
5858
cmovz ebx, esi /* on child we close the server sock instead */
5959

6060
/* close(sock) */

pwnlib/shellcraft/templates/i386/linux/mprotect_all.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
%endif
2323
${label}:
2424
${i386.linux.syscall('SYS_mprotect', 'ebx', 'ecx', 'PROT_READ | PROT_WRITE | PROT_EXEC')}
25-
${i386.linux.mov('ecx', 0x1000)}
25+
${i386.mov('ecx', 0x1000)}
2626
add ebx, ecx
2727
jnz ${label}

0 commit comments

Comments
 (0)