Commit Graph

1539 Commits

Author SHA1 Message Date
MinimalEffort07 4fde3e898c
Issue #1667 Display OS Information In Bugreport (#1683) 2023-04-23 19:13:10 +02:00
theguy147 e1dad2e8c7
feat: make qemu-system tests more flexible (#1682) 2023-04-22 20:11:33 -07:00
theguy147 91c72a001e
feat: use pytest for qemu-system tests (#1679)
* feat: use pytest for qemu-system tests

* CI: update qemu workflow

* feat: make tests aware of ARCH and KERNEL_TYPE
2023-04-22 11:31:45 +02:00
AlEscher 424c21a6be
Allow garuda install (#1680) 2023-04-22 11:20:54 +02:00
Disconnect3d e5b188f1cf
Update CONTRIBUTING.md (#1681) 2023-04-22 11:19:32 +02:00
Olivia Lucca Fraser e6037f547a
Added support for Anthropic's Claude LLM as a backend for the ai tool (#1661)
* ai plugin

* ai plugin ready to ship

* ai plugin ready to use

* textwrap on the ai's answer

* linted ai.py

* relaxed openai version requirement

* added pandas to requirements

* removed dependency on openai module, using requests instead

* removed dependency on openai module, using requests instead

* incorporating suggestions on PR

* added types requests and bumped requests version up to the version i'm using here

* lowering version req on requests for ubuntu 18 compat

* removed some 'if True' kludges that i was using to debug things at one point

* better error handling

* more config parameters for ai

* fixed a few config issues

* fixed bug in gdb list command

* now uses chatgpt's gpt-3.5-turbo model, instead of text-davinci-003, and follows a conversational protocol instead of completion.

* added support for anthropic's claude

* linted

* tidied up main function
2023-04-19 21:59:06 +02:00
theguy147 d80e55c4e3
add `krelease()` function (#1673) 2023-04-19 12:51:58 -07:00
dabrd 758fb9cb82
Corrected year in README (#1674)
Co-authored-by: db <db@example.com>
2023-04-18 19:53:30 +02:00
Albert Koczy d3b1a91c1c
Add support for Arch Linux ARM in setup.sh (#1672)
Technically Arch Linux ARM is a separate distro from the x86_64 Arch Linux, but it uses pcaman and the same package names. So it installs just fine, just needs to be detected properly.
2023-04-18 19:36:06 +02:00
_|+ 65b70c5faa
Port pwntools asm into pwndbg (#1384) 2023-04-14 22:29:07 +02:00
CptGibbon 17078ce400
Resolve some `find_fake_fast` command issues (#1640)
* find_fake_fast robustness

* Use size_sz in place of "ptrsize"

* Adhere to Flake8 style guide
2023-04-14 22:27:21 +02:00
Albert Koczy 6f2f5279c6
feature: Add `killthreads` command (closes #1580) (#1581)
* feature: Add `killthreads` command (closes #1580)

This command allows the user to quickly kill multiple  threads by
specyfying their ids as arguments to this command. It also supports
the `--all` flag, which will kill overy thread except the currently
selected one. This is useful for use with the `checkpoint` command.

The killing is done by calling `pthread_exit(0)`.

* fix: try fixing building test binaries by enabling -lpthread

* fix: remove error message check when calling pthread_exit

Removed the message check, because the error messages difffer between
versions of GDB.

* fix: Improve UX of the killthreads command

Add an extended description of the command, some validation on the thread IDs
and suppress GDB output.

* fix: lint

* fix: put the multiline help text in the correct place

* tests: fix test failing due to a race condition when running in parrallel to other tests

Replaced asserts with loops which wait for a cundition to be met, so that the tests doesn't fail due to scheduling issues.

* tests: add more fixes for race conditions in test_killthreads

* fix: lint

* Update pwndbg/commands/killthreads.py

* tests: Wait for exactly three threads

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-04-14 19:02:26 +02:00
CptGibbon e744ebf3fb
Add smallbins size tests for x64 & i386_big (#1669) 2023-04-11 19:23:53 +02:00
Disconnect3d 96482a60ce
CI: remove Ubuntu 18.04 from lint and tests builds (#1670) 2023-04-11 19:21:29 +02:00
CptGibbon 386a0ac756
Better `--verbose` flag descriptions (#1665) 2023-04-09 23:58:32 +02:00
Alex Chen ca5e6f579a
Add update mode for setup.sh (#1660)
* Add update mode for setup.sh

* Use basic for loop instead of getopts

* Lint
2023-04-06 11:02:36 +02:00
CptGibbon 9d3ee52ea6
Largebins size range tests for x64 & i386_big (#1658)
* Add largebins size range tests for x64 & i386_big

* Don't run i386_big test on unsupported platforms
2023-04-04 10:47:14 +02:00
Alan Li ceb7258de6
Fix the unused arguments of heap commands (#1659) 2023-04-04 10:45:59 +02:00
Squirre17 3ba5c1555f
Fixed a crash that caused formatting failure in readlink when qemu returns None as the pid. (#1644)
* Fixed a crash that caused formatting failure in readlink when qemu returns None as the pid.

* Formated code

* Update pwndbg/arguments.py

* Assign a pid prevent repetitive calls.

* Format it

* remove the warning

* add a comment about the senario that PID is None in qemu

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-04-02 20:50:43 +02:00
CptGibbon c02f18e227
Change `verbose` flag action on *bins commands (#1655) 2023-04-02 20:50:16 +02:00
Alan Li 96d98786d4
Search GLIBC version in .rodata section of libc.so (#1656) 2023-04-02 20:49:19 +02:00
Disconnect3d 65358b774e
Update slab.py (#1654) 2023-03-29 17:51:16 +02:00
Gulshan Singh 3c9d09b518
Add docs on adding commands and config options (#1507)
* Add docs on adding commands and config options

* Update DEVELOPING.md
2023-03-29 00:02:35 -07:00
Gulshan Singh f80dd85fe6 Add types-request to dev-requirements.txt 2023-03-28 21:55:27 -07:00
Alan Li f90dcc2b39
Add some basic heap heuristics supports for riscv and powerpc (#1649)
* Add some basic heap heuristics support for riscv and powerpc

Use the relocation section to find the main_arena address if possible

* Refactor the code we used to get the field offset
2023-03-28 11:08:07 +02:00
Xeonacid 38a1ac6d99
Support riscv syscall and ABI; Fix riscv retval register (#1651)
* Fix riscv retval register; Use riscv as name

riscv64 and riscv32 (if we add later) use the same register set

* Support riscv syscall and ABI
2023-03-28 11:06:30 +02:00
Xeonacid d7f459c169
Fix linux arm/aarch64/ppc(64) syscall abi (#1639)
* Fix linux_ppc(64)_syscall abi

The system call number is specified in r0.

There is a maximum of 6 integer parameters to a syscall, passed in r3-r8.

* Fix ppc syscall revert r9 back

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>

* Remove r6/x6 from arm/aarch64 syscall

* Update pwndbg/lib/abi.py

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
2023-03-25 16:46:47 +01:00
Alan Li 814eb33417
Fix wrong `MALLOC_ALIGNMENT` for powerpc (#1646)
* Fix the wrong MALLOC_ALIGNMENT

If `2 * SIZE_SZ < __alignof__ (long double)`, `MALLOC_ALIGNMENT` will be  `__alignof__ (long double)`.

See https://elixir.bootlin.com/glibc/glibc-2.37/source/sysdeps/generic/malloc-alignment.h#L27

* Hardcoded supports powerpc's MALLOC_ALIGNMENT for GDB < 8.2
2023-03-25 12:56:06 +01:00
Alan Li 9a913e2651
Fix the wrong type for `tcache_count` (#1648) 2023-03-24 15:24:04 +01:00
Disconnect3d 7ba82ef571
Fix shfmt lint issue in setup.sh (#1642) 2023-03-24 15:14:30 +01:00
Xeonacid 59e759e036
Fix missing length in mprotect doc example (#1641) 2023-03-22 07:28:09 +01:00
Disconnect3d 66aa6af19c
Update tips.py with `info args` and `set scheduler-locking on` (#1636)
* Update tips.py with `info args` and `set scheduler-locking on`

* Update tips.py

Fix nested quotes

* Update tips.py

Happy lint
2023-03-21 11:01:01 +01:00
Disconnect3d cf63cc326e
Fix setup.sh on MacOS due to gnu vs bsd sed (#1635) 2023-03-20 00:49:01 +01:00
Disconnect3d 35769a88ab
Set version to 2023.03.19 (#1633) 2023-03-19 11:55:50 +01:00
Disconnect3d 5cf18e18e8
fetch GDB version via regex to fit Fedora format (#1632)
Co-authored-by: disconnect3d <dominik.b.czarnota+pwndbg@gmail.com>
2023-03-18 23:56:45 +01:00
Alan Li 36972fd982
Fix the issues when finding `tcache` for some 32-bit architectures (#1625)
* Fix the wrong tcache result for 32-bit architectures

* Remove redundant code

`arena.active_heap.start` already done i686 alginment

* Use `.heaps[0]` instead of `.active_heap`

https://github.com/pwndbg/pwndbg/pull/1625#issuecomment-1470453812
2023-03-17 21:53:48 +01:00
Alan Li f2fb803957
Fix the bug when using the heap heuristic on big-endian architectures (#1627) 2023-03-17 21:53:09 +01:00
CptGibbon b6e742ce38
Bump Zig version (#1629) 2023-03-16 18:16:49 +01:00
Cycatz 80fbb375a7
Improve installation process (#1620)
Now the installation process contains the following steps:
1. Check for any line with source <gdbinit.py> before installation
2. If any, ask the user if they want to proceed
3. After the installation, comment out old source <gdbinit.py> lines if any and add a new source <gdbinit.py> line.

A check for presence of the line set debuginfod enabled on is also added to avoid being appended repeatedly.
2023-03-15 20:30:24 +01:00
CptGibbon 64f4d6b6da
Correct largebin size lookups on i386 (#1623)
* Add largebin reverse lookup tables

* Don't use None value for bin 95 size on i386

* Clarify "bin 95" comment

* Add comment to tables

* Immutable tables

* Make tables class attributes
2023-03-15 20:29:55 +01:00
CptGibbon ed73d38f83
Use `malloc_alignment` in place of `arch.ptrsize` in `spaces_table` (#1621) 2023-03-15 18:36:32 +01:00
Disconnect3d be306da255
Fix #808: set search-memory-packet off only on GDB<=9 (#1619)
I can confirm the search bug to happen on GDB 9.2, but not on GDB 10.2:

```
pwndbg> version
Gdb:      9.2
Python:   3.8.10 (default, Nov 14 2022, 12:59:47)  [GCC 9.4.0]
Pwndbg:   1.1.1 build: a3f12bc
Capstone: 4.0.1024
Unicorn:  2.0.1

pwndbg> search "GNU C"
Searching for value: 'GNU C'

pwndbg> set remote search-memory-packet off

pwndbg> search "GNU C"
Searching for value: 'GNU C'
libc-2.31.so    0x7ffff7f85b80 0x694c204320554e47 ('GNU C Li')
libc-2.31.so    0x7ffff7f85c9e 'GNU CC version 9.3.0.\nlibc ABIs: UNIQUE IFUNC ABSOLUTE\nFor bug reporting instructions, please see:\n<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>.\n'
```
2023-03-10 04:41:22 +01:00
CptGibbon a3f12bc2c1
Add `largebin_index_32_big` macro (#1617) 2023-03-10 00:32:42 +01:00
Olivia Lucca Fraser ce8e72eed1
ai tool now uses ChatGPT model (#1614)
* ai plugin

* ai plugin ready to ship

* ai plugin ready to use

* textwrap on the ai's answer

* linted ai.py

* relaxed openai version requirement

* added pandas to requirements

* removed dependency on openai module, using requests instead

* removed dependency on openai module, using requests instead

* incorporating suggestions on PR

* added types requests and bumped requests version up to the version i'm using here

* lowering version req on requests for ubuntu 18 compat

* removed some 'if True' kludges that i was using to debug things at one point

* better error handling

* more config parameters for ai

* fixed a few config issues

* fixed bug in gdb list command

* now uses chatgpt's gpt-3.5-turbo model, instead of text-davinci-003, and follows a conversational protocol instead of completion.

* ensuring backwards compatibility with older models, like text-davinci-003

* removed unneeded host and path vars
2023-03-09 02:32:34 +01:00
CptGibbon d0f55d5cf9
Display bin size range in `largebins` command output (#1613)
* Display bin size range in `largebins` command

* Remove `infinity_symbol` variable

* Remove unnecessary assignment
2023-03-09 02:31:27 +01:00
CptGibbon a847cbba92
Add headers to `arenas` command output (#1612) 2023-03-08 02:02:07 +01:00
neryaz bdbd4ed7db
Add print all chunks in vis_heap_chunks (#1604)
* Changing the arguments to vis_heap_chunks to be clearer

1. --native to --beyond_top
2. --display_all to --no_truncate

* Add print all chunks to vis_heap_chunks

* Preventing the use of the all_chunks argument together with the count argument in vis_heap_chunks

* Use linting for heap.py

* Fix test_vis_heap_chunks.py
According to cdd71a1d82 --display_all/-d moved to --no_truncate/-n

---------

Co-authored-by: Nerya Zadkani <nerya@tokagroup.com>
2023-03-07 22:58:39 +01:00
Disconnect3d 86b512979c
Fix #1610: symbol.get with duplicated symbols (#1611)
* Fix #1610: symbol.get with duplicated symbols

See https://github.com/pwndbg/pwndbg/issues/1610

* fix ubuntu 18.04 build

* fix ubuntu 18.04 build
2023-03-07 05:00:09 +01:00
Disconnect3d 9ac6e679e5
symbol.py: remove _add_main_symbol_to_exe (#1609)
It seems this function is redundant. If you do:

```
gdbserver 0.0.0.0:1234 ./a.out
```

on a local machine and then do `gdb ./a.out --ex 'target remote :1234'`
the `_add_main_symbol_to_exe` will kick off and run its
`add-symbol-file` command to add the symbols from the binary. However,
the GDB already loaded the binary symbols and so we will do it for the
second time. As a result, we get something like this:

```
pwndbg> info symbol main
main in section .text of /pwndbg/bug/vaccine
main in section .text of /pwndbg/bug/vaccine
```

This function has been in Pwndbg since always and I am not sure why we
needed it. Perhaps an old GDB did not download the binary from the
remote target, but since now GDB does this automagically, this function
seems redundant.

Just for the sake of documenting it, here is how a symbol appears if you
connect to a remote target on a different machine without Pwndbg (the
GDB downloads the binary itself and loads its symbols):

```
(gdb) p main
$1 = {<text variable, no debug info>} 0x55555555466a <main>
(gdb) info symbol main
main in section .text of target:/home/dc/a.out
```
2023-03-06 11:28:57 +01:00
Disconnect3d ffad9be01e
tests.sh: check for parallel_env requirement (closes #1606) (#1607)
* tests.sh: check for parallel_env requirement (closes #1606)

* fix shlint
2023-03-06 03:04:11 +01:00