internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Gallopsled/pwntools

Issue:
spawn_process + gdb
Would be neat to be able to auto-attach to each process spawned with a breakpoint at the entry point



Discussion:
Something like this?

```
l = listen(0)
l.spawn_process(['gdbserver', 'localhost:1234', '/bin/bash'])
r = remote('127.0.0.1', l.lport)
gdb.attach(('127.0.0.1', 1234))
```

I it would make sense to wrap something like that in a function. Perhaps even reuse some of the code from ssh_gdb.

Ideally we should not have to hardcode a port for the gdb-server either, but I was too lazy to write the port parser.


Resolving patch:
diff --git a/pwnlib/gdb.py b/pwnlib/gdb.py
--- a/pwnlib/gdb.py
+++ b/pwnlib/gdb.py
@@ -1,8 +1,60 @@
-import os, tempfile, re, shlex
+import os, tempfile, re, shlex, subprocess
 from . import log
 from .util import misc, proc
 from . import tubes, elf
 
+def debug(args, exe=None, execute=None, ssh=None):
+    """debug(args) -> tube
+
+    Launch a GDB server with the specified command line,
+    and launches GDB to attach to it.
+
+    Args:
+        args: Same args as passed to pwnlib.tubes.process
+        ssh: Remote ssh session to use to launch the process.
+          Automatically sets up port forwarding so that gdb runs locally.
+
+    Returns:
+        A tube connected to the target process
+    """
+    args      = ['gdbserver', 'localhost:0'] + args
+
+    if not ssh:
+        execute = tubes.process.process
+        which   = misc.which
+    if ssh:
+        execute = ssh.run
+        which   = ssh.which
+
+    # Make sure gdbserver is installed
+    if not which('gdbserver'):
+        log.error("gdbserver is not installed")
+
+    gdbserver = execute(args)
+
+    # Process /bin/bash created; pid = 14366
+    # Listening on port 34816
+    process_created = gdbserver.recvline()
+    listening_on    = gdbserver.recvline()
+
+    port     = int(listening_on.split()[-1])
+
+    listener = remote = None
+
+    if ssh:
+        remote   = ssh.connect_remote('127.0.0.1', port)
+        listener = tubes.listen.listen(0)
+        port     = listener.lport
+    elif not exe:
+        exe = misc.which(args[0])
+
+    result = attach(('127.0.0.1', port), exe=exe)
+
+    if ssh:
+        remote <> listener.wait_for_connection()
+
+    return gdbserver
+
 def attach(target, execute = None, exe = None, arch = None):
     """attach(target, execute = None, exe = None, arch = None) -> None
 
@@ -251,7 +303,7 @@ def find_module_addresses(binary, ssh=None, ulimit=False):
         local_libs = ssh.libs(binary)
 
     else:
-        runner     = lambda x: tubes.process.process(shlex.split(x))
+        runner     = tubes.process.process
         local_elf  = elf.ELF(binary)
         local_libs = local_elf.libs
 
@@ -267,6 +319,8 @@ def find_module_addresses(binary, ssh=None, ulimit=False):
     if ulimit:
         cmd = 'sh -c "(ulimit -s unlimited; %s)"' % cmd
 
+    cmd = shlex.split(cmd)
+
     with runner(cmd) as gdb:
         gdb.send("""
         set prompt


Test patch:
Repository: Gallopsled/pwntools

Issue:
Creating multiple rop objects is veeery noisy
I get this A LOT:

```
[*] Found gadgets for './ropasaurusrex-85a84f36f81e11f720b1cf5ea0d1fb0d5a603c0d' in cache '/tmp/pwntoo    ls-rop-cache/ropasaurusrex-85a84f36f81e11f720b1cf5ea0d1fb0d5a603c0d c5bb68949dcc3264cd3a560c05d0b5    66-0x8048000'
```



Discussion:
Maybe it should be shorter and/or only appear once per program?


Resolving patch:
diff --git a/pwnlib/rop.py b/pwnlib/rop.py
--- a/pwnlib/rop.py
+++ b/pwnlib/rop.py
@@ -360,7 +360,7 @@ def __cache_load(self, elf):
         filename = self.__get_cachefile_name(elf)
 
         if os.path.exists(filename):
-            log.info("Found gadgets for %r in cache %r" % (elf.file.name,filename))
+            log.info("Found cached gadgets for %r" % (elf.file.name))
             return eval(file(filename).read())
 
     def __cache_save(self, elf, data):


Test patch:
Repository: Gallopsled/pwntools

Issue:
Statically linked ELF file cannot be loaded in pwntools
The .rela.plt section in a statically linked ELF file has sh_link set to zero, causing an attribute error in [elf.py](https://github.com/Gallopsled/pwntools/blob/master/pwnlib/elf.py#L240)

``` bash
user@ubuntu:~/src$ cat > static.c <<EOF
int main() { return 0; }
EOF
user@ubuntu:~/src$ gcc -o static static.c -static
user@ubuntu:~/src$ python -c "from pwn import *; elf = ELF('./static');"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pwntools-2.1.3-py2.7.egg/pwnlib/elf.py", line 58, in __init__
    self._populate_got_plt()
  File "/usr/local/lib/python2.7/dist-packages/pwntools-2.1.3-py2.7.egg/pwnlib/elf.py", line 240, in _populate_got_plt
    symbol   = sym_rel_plt.get_symbol(sym_idx)
AttributeError: 'NullSection' object has no attribute 'get_symbol'
```



Discussion:

Resolving patch:
diff --git a/pwnlib/elf.py b/pwnlib/elf.py
--- a/pwnlib/elf.py
+++ b/pwnlib/elf.py
@@ -6,7 +6,7 @@
 from elftools.elf.elffile import ELFFile
 from elftools.elf.sections import SymbolTableSection
 from elftools.elf.descriptions import describe_e_type
-from elftools.elf.constants import P_FLAGS
+from elftools.elf.constants import P_FLAGS, SHN_INDICES
 
 def load(*args, **kwargs):
     """Compatibility wrapper for pwntools v1"""
@@ -231,16 +231,17 @@ def _populate_got_plt(self):
         # Find the relocation section for PLT
         rel_plt = next(s for s in self.sections if s.header.sh_info == self.sections.index(plt))
 
-        # Find the symbols for the relocation section
-        sym_rel_plt = self.sections[rel_plt.header.sh_link]
+        if rel_plt.header.sh_link != SHN_INDICES.SHN_UNDEF:
+            # Find the symbols for the relocation section
+            sym_rel_plt = self.sections[rel_plt.header.sh_link]
 
-        # Populate the GOT
-        for rel in rel_plt.iter_relocations():
-            sym_idx  = rel.entry.r_info_sym
-            symbol   = sym_rel_plt.get_symbol(sym_idx)
-            name     = symbol.name
+            # Populate the GOT
+            for rel in rel_plt.iter_relocations():
+                sym_idx  = rel.entry.r_info_sym
+                symbol   = sym_rel_plt.get_symbol(sym_idx)
+                name     = symbol.name
 
-            self.got[name] = rel.entry.r_offset
+                self.got[name] = rel.entry.r_offset
 
         # Depending on the architecture, the beginning of the .plt will differ
         # in size, and each entry in the .plt will also differ in size.


Test patch:
Repository: Gallopsled/pwntools

Issue:
gdb.attach does not work by default on Ubuntu
While this is a common issue on Ubuntu, `ptrace_scope` must be set to `0` for modern Ubuntu to attach to a running PID with GDB.

We should attempt to detect this case and print out a warning message.



Discussion:

Resolving patch:
diff --git a/pwnlib/gdb.py b/pwnlib/gdb.py
--- a/pwnlib/gdb.py
+++ b/pwnlib/gdb.py
@@ -29,6 +29,16 @@ def attach(target, execute = None, exe = None, arch = None):
     Returns:
       :const:`None`
 """
+    # if ptrace_scope is set and we're not root, we cannot attach to a running process
+    try:
+        ptrace_scope = open('/proc/sys/kernel/yama/ptrace_scope').read().strip()
+        if ptrace_scope != '0' and os.geteuid() != 0:
+            msg =  'Disable ptrace_scope to attach to running processes.\n'
+            msg += 'More info: http://askubuntu.com/q/41629'
+            log.warning(msg)
+    except IOError:
+        pass
+
     # if execute is a file object, then read it; we probably need to run some
     # more gdb script anyway
     if execute:


Test patch:
Repository: Gallopsled/pwntools

Issue:
asm() does not properly delete its temporary diretories
See title



Discussion:

Resolving patch:
diff --git a/pwnlib/asm.py b/pwnlib/asm.py
--- a/pwnlib/asm.py
+++ b/pwnlib/asm.py
@@ -337,6 +337,7 @@ def asm(shellcode, vma = 0, **kwargs):
             >>> asm("ldr r0, =SYS_select", arch = 'arm', os = 'linux', bits=32)
             '\x04\x00\x1f\xe5R\x00\x90\x00'
     """
+    result = ''
 
     with context.local(**kwargs):
         osx = (platform.system() == 'Darwin')
@@ -366,21 +367,18 @@ def asm(shellcode, vma = 0, **kwargs):
                     [which('readelf'), '-r', step2]
                 ).strip()
                 if len(relocs.split('\n')) > 1:
-                    raise Exception(
-                        'There were relocations in the shellcode:\n\n%s' % relocs
-                    )
+                    log.error('Shellcode contains relocations:\n%s' % relocs)
 
             _run(objcopy + [step2, step3])
 
             with open(step3) as fd:
-                return fd.read()
+                result = fd.read()
 
         except:
             log.error("An error occurred while assembling:\n%s" % code)
-            raise
         else:
             shutil.rmtree(tmpdir)
-
+            return result
 
 def disasm(data, vma = 0, **kwargs):
     """disasm(data, ...) -> str
@@ -416,6 +414,7 @@ def disasm(data, vma = 0, **kwargs):
           >>> print disasm('4ff00500'.decode('hex'), arch = 'thumb', bits=32)
              0:   f04f 0005       mov.w   r0, #5
     """
+    result = ''
 
     with context.local(**kwargs):
         arch   = context.arch
@@ -442,6 +441,7 @@ def disasm(data, vma = 0, **kwargs):
             objcopy += ['-w', '-N', '*']
 
         try:
+
             with open(step1, 'w') as fd:
                 fd.write(data)
 
@@ -449,11 +449,15 @@ def disasm(data, vma = 0, **kwargs):
 
             output0 = subprocess.check_output(objdump + [step2])
             output1 = output0.split('<.text>:\n')
+
             if len(output1) != 2:
-                raise IOError('Something went wrong with objdump:\n\n%s' % output0)
-            else:
-                return output1[1].strip('\n').rstrip().expandtabs()
+                log.error('Could not find .text in objdump output:\n%s' % output0)
+
+
+            result = output1[1].strip('\n').rstrip().expandtabs()
         except:
-            raise
+            log.error("An error occurred while disassembling:\n%s" % data)
         else:
             shutil.rmtree(tmpdir)
+            return result
+


Test patch:
Repository: Gallopsled/pwntools

Issue:
pwnlib.util.fiddling.hexdump() no longer has colors
The colors used to be so pretty but now they are gone because of this piece of code: https://github.com/Gallopsled/pwntools/blob/master/pwnlib/util/fiddling.py#L460

It looks like it was added as a quick-fix to overcome some issue, but I can't figure out which. Thoughts,  @zachriggle?



Discussion:
Yeah looks like left over code from troubleshooting
On Sun, Dec 21, 2014 at 6:52 AM br0ns notifications@github.com wrote:

> Assigned #199 https://github.com/Gallopsled/pwntools/issues/199 to
> @zachriggle https://github.com/zachriggle.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/Gallopsled/pwntools/issues/199#event-210634925.


Resolving patch:
diff --git a/pwnlib/util/fiddling.py b/pwnlib/util/fiddling.py
--- a/pwnlib/util/fiddling.py
+++ b/pwnlib/util/fiddling.py
@@ -457,7 +457,7 @@ def _hexiichar(c):
     'ff':           text.green,
 }
 
-if 1 or not sys.stdout.isatty():
+if not sys.stdout.isatty():
   default_style = {
     'marker': lambda x:x,
     'nonprintable': lambda x:x,


Test patch:
Repository: Gallopsled/pwntools

Issue:
Pwnlib loads very slowly
On my system it takes two thirds of a second to load pwnlib:

```
~> time python -c "import pwn"

real    0m0.641s
user    0m0.576s
sys     0m0.044s
```

I've tracked down the culprit: `pwnlib.util.web` imports the `requests` module which takes forever (https://github.com/Gallopsled/pwntools/blob/master/pwnlib/util/web.py#L3).

I suggest we load `requests` lazily in `pwnlib.util.web.wget()`.



Discussion:
Is the load time any better with 

`import requests`

vs 

`from requests import *`

Also, the load time on Travis is [reasonable](https://travis-ci.org/Gallopsled/pwntools#L817) (0.3-0.4s).

Do you still see this behavior in a fresh VM on your local machine, or in a fresh `virtualenv`?

I've got no qualm with deferring the load, just trying to figure out more about the _why_ than the _what_


Resolving patch:
diff --git a/pwnlib/util/web.py b/pwnlib/util/web.py
--- a/pwnlib/util/web.py
+++ b/pwnlib/util/web.py
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 import os, tempfile, logging
-from requests import *
 from .misc import size
 log = logging.getLogger(__name__)
 
@@ -25,6 +24,8 @@ def wget(url, save=None, timeout=5, **kwargs):
       >>> result == file('robots.txt').read()
       True
     """
+    from requests import *
+
     with log.progress("Downloading '%s'" % url) as w:
         w.status("Making request...")
 


Test patch:
Repository: Gallopsled/pwntools

Issue:
SyntaxWarning in pwnlib.util.web
This line generates a `SyntaxWarning`: https://github.com/Gallopsled/pwntools/blob/master/pwnlib/util/web.py#L27

Either we should use qualified names or only import the names that we need.  My votes goes toward the former.

SyntaxWarning in pwnlib.util.web
This line generates a `SyntaxWarning`: https://github.com/Gallopsled/pwntools/blob/master/pwnlib/util/web.py#L27

Either we should use qualified names or only import the names that we need.  My votes goes toward the former.



Discussion:

Resolving patch:
diff --git a/pwnlib/util/web.py b/pwnlib/util/web.py
--- a/pwnlib/util/web.py
+++ b/pwnlib/util/web.py
@@ -24,12 +24,12 @@ def wget(url, save=None, timeout=5, **kwargs):
       >>> result == file('robots.txt').read()
       True
     """
-    from requests import *
+    import requests
 
     with log.progress("Downloading '%s'" % url) as w:
         w.status("Making request...")
 
-        response = get(url, stream=True, **kwargs)
+        response = requests.get(url, stream=True, **kwargs)
 
         if not response.ok:
             w.failure("Got code %s" % response.status_code)


Test patch:
Repository: Gallopsled/pwntools

Issue:
Our readline implementation is broken
The current readline implementation (which replaces `raw_input()`) is broken.  I'm not sure how it has been working before.

The implementation shows a lot of signs of being POC code and should probably be rewritten along with `pwnlib/term/term.py` at some point.  But the current issue should be fixed right away.



Discussion:

Resolving patch:
diff --git a/pwnlib/term/readline.py b/pwnlib/term/readline.py
--- a/pwnlib/term/readline.py
+++ b/pwnlib/term/readline.py
@@ -83,6 +83,7 @@ def clear():
     redisplay()
 
 def redisplay():
+    global suggest_handle
     if buffer_handle:
         if show_suggestions and suggest_hook:
             suggestions = suggest_hook(buffer_left, buffer_right)


Test patch:
Repository: Gallopsled/pwntools

Issue:
Add a rst file for useragents.
There is no rst file for the useragents module, so there is no documentation on readthedocs either.

Found in #211.



Discussion:
There seems to be a lot of documentation missing. We do not have a web.rst either.


Resolving patch:
diff --git a/pwnlib/useragents.py b/pwnlib/useragents.py
--- a/pwnlib/useragents.py
+++ b/pwnlib/useragents.py
@@ -1,5 +1,5 @@
 """
-Database of 22,000 user agent strings
+Database of >22,000 user agent strings
 """
 __all__ = ['getall', 'random']
 
@@ -52,6 +52,6 @@ def random():
     >>> import random as randommod
     >>> randommod.seed(1)
     >>> random()
-    'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; FDM)'
+    'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FunWebProducts; FunWebProducts-MyTotalSearch; iebar)'
     """
     return randommod.choice(list(_load()))
diff --git a/pwnlib/util/hashes.py b/pwnlib/util/hashes.py
--- a/pwnlib/util/hashes.py
+++ b/pwnlib/util/hashes.py
@@ -1,3 +1,6 @@
+"""
+Functions for computing various hashes of files and strings.
+"""
 import hashlib
 
 for _algo in hashlib.algorithms:
diff --git a/pwnlib/util/web.py b/pwnlib/util/web.py
--- a/pwnlib/util/web.py
+++ b/pwnlib/util/web.py
@@ -17,10 +17,12 @@ def wget(url, save=None, timeout=5, **kwargs):
     Example:
 
       >>> url    = 'http://httpbin.org/robots.txt'
-      >>> with context.local(log_level='ERROR'): result = wget(url)
+      >>> with context.local(log_level='ERROR'):
+      ...     result = wget(url)
       >>> result
-      'User-agent: *\nDisallow: /deny\n'
-      >>> with context.local(log_level='ERROR'): wget(url, True)
+      'User-agent: *\\nDisallow: /deny\\n'
+      >>> with context.local(log_level='ERROR'):
+      ...     _ = wget(url, True)
       >>> result == file('robots.txt').read()
       True
     """
@@ -67,4 +69,3 @@ def wget(url, save=None, timeout=5, **kwargs):
             w.success('%s' % size(total_data))
 
         return total_data
-


Test patch:
Repository: Gallopsled/pwntools

Issue:
`pwnlib.tube.tubes.recvline` has lost a feature
We used to be able to receive until a line containing one of a set of delimiters: https://github.com/Gallopsled/pwntools/blob/c07637d05b397527f0ae3a815ffc1328a039c404/pwnlib/tubes/tube.py#L225-L256.



Discussion:
This functionality is improperly worded, since these are not "delimiters" by any meaning.

Would an acceptable alternative be a separate routine, `recvline_contains` which is a wrapper around `recvline_pred`?


Resolving patch:
diff --git a/pwnlib/tubes/tube.py b/pwnlib/tubes/tube.py
--- a/pwnlib/tubes/tube.py
+++ b/pwnlib/tubes/tube.py
@@ -453,6 +453,31 @@ def recvline_pred(self, pred, keep = False, timeout = None):
 
         return ''
 
+    def recvline_contains(self, items, keep = False, timeout = None):
+        r"""
+        Receive lines until one line is found which contains at least
+        one of `items`.
+
+        Arguments:
+            items(str,tuple): List of strings to search for, or a single string.
+            keep(bool): Return lines with newlines if ``True``
+            timeout(int): Timeout, in seconds
+
+        Examples:
+
+            >>> t = tube()
+            >>> t.recv_raw = lambda n: "Hello\nWorld\nXylophone\n"
+            >>> t.recvline_contains('r')
+            'World'
+        """
+        if isinstance(items, (str,unicode)):
+            delims = (items,)
+
+        def pred(line):
+            return any(d in line for d in items)
+
+        return self.recvline_pred(pred, keep, timeout)
+
     def recvline_startswith(self, delims, keep = False, timeout = None):
         r"""recvline_startswith(delims, keep = False, timeout = None) -> str
 


Test patch:
Repository: Gallopsled/pwntools

Issue:
`pwnlib.tubes.tube.recvrepeat()` and `pwnlib.tubes.tube.recvall()` should never raise `EOFError`
If the connection is closed while calling these functions, we should simply return the received data.



Discussion:

Resolving patch:
diff --git a/pwnlib/tubes/tube.py b/pwnlib/tubes/tube.py
--- a/pwnlib/tubes/tube.py
+++ b/pwnlib/tubes/tube.py
@@ -594,7 +594,10 @@ def recvrepeat(self, timeout = None):
             'd'
         """
 
-        while self._fillbuffer(timeout=timeout):
+        try:
+            while self._fillbuffer(timeout=timeout):
+                pass
+        except EOFError:
             pass
 
         return self.buffer.get()


Test patch:
Repository: Gallopsled/pwntools

Issue:
MemLeak decorator optional
We should make the `@MemLeak` decorator optional for passing into `DynELF`.  This would make the code a bit less intimidating to a new user.

We can easily check to see if the first argument passed in has been decorated already.  

``` python
>>> @MemLeak
... def x(): pass
>>> isinstance(x, MemLeak)
True
```



Discussion:

Resolving patch:
diff --git a/pwnlib/dynelf.py b/pwnlib/dynelf.py
--- a/pwnlib/dynelf.py
+++ b/pwnlib/dynelf.py
@@ -1,3 +1,53 @@
+"""
+Resolve symbols in loaded, dynamically-linked ELF binaries.
+Given a function which can leak data at an arbitrary address,
+any symbol in any loaded library can be resolved.
+
+Example
+^^^^^^^^
+
+::
+
+    # Assume a process or remote connection
+    p = process('./pwnme')
+
+    # Declare a function that takes a single address, and
+    # leaks at least one byte at that address.
+    def leak(address):
+        data = p.read(address, 4)
+        log.debug("%#x => %s" % (address, (data or '').encode('hex')))
+        return data
+
+    # For the sake of this example, let's say that we
+    # have any of these pointers.  One is a pointer into
+    # the target binary, the other two are pointers into libc
+    main   = 0xfeedf4ce
+    libc   = 0xdeadb000
+    system = 0xdeadbeef
+
+    # With our leaker, and a pointer into our target binary,
+    # we can resolve the address of anything.
+    #
+    # We do not actually need to have a copy of the target
+    # binary for this to work.
+    d = DynELF(leak, main)
+    assert d.lookup(None,     'libc') == libc
+    assert d.lookup('system', 'libc') == system
+
+    # However, if we *do* have a copy of the target binary,
+    # we can speed up some of the steps.
+    d = DynELF(leak, main, elf=ELF('./pwnme'))
+    assert d.lookup(None,     'libc') == libc
+    assert d.lookup('system', 'libc') == system
+
+    # Alternately, we can resolve symbols inside another library,
+    # given a pointer into it.
+    d = DynELF(leak, libc + 0x1234)
+    assert d.lookup('system')      == system
+
+DynELF
+==========
+"""
 from .elf     import *
 from .memleak import MemLeak
 from .context import context
@@ -108,6 +158,9 @@ def __init__(self, leak, pointer=None, elf=None):
 
         pointer = pointer or elf.address
 
+        if not isinstance(leak, MemLeak):
+            leak = MemLeak(leak)
+
         self.leak    = leak
         self.libbase = self._find_base(pointer or elf.address)
 


Test patch:
Repository: Gallopsled/pwntools

Issue:
2 doctests in proc fail on debian
We have some tests that assume pid 1 is init , and they fail on debian versions that use systemd. I can't really think of tests that are less platform-specific, any suggestions?



Discussion:
Can you post the output of the failing tests?

Zach Riggle

> On Dec 25, 2014, at 7:21 AM, Kristoffer Søholm notifications@github.com wrote:
> 
> We have some tests that assume pid 1 is init , and they fail on debian versions that use systemd. I can't really think of tests that are less platform-specific, any suggestions?
> 
> —
> Reply to this email directly or view it on GitHub.

I had updated some of those tests to do

> > > os.getpid() in pidof("Python")

And similar stuff. I guess it was never uploaded, though.

Zach Riggle

> On Dec 25, 2014, at 7:21 AM, Kristoffer Søholm notifications@github.com wrote:
> 
> We have some tests that assume pid 1 is init , and they fail on debian versions that use systemd. I can't really think of tests that are less platform-specific, any suggestions?
> 
> —
> Reply to this email directly or view it on GitHub.

> I had updated some of those tests to do
> 
> > > os.getpid() in pidof("Python")
> > > And similar stuff. I guess it was never uploaded, though.

That makes the examples a bit ugly, but it would work. Do you still have those changes somewhere?

@zachriggle ping?

I did have those changes, then 31c3 happened and I nuked everything.  I no longer have this info, but I can recreate real quick.


Resolving patch:
diff --git a/pwnlib/util/proc.py b/pwnlib/util/proc.py
--- a/pwnlib/util/proc.py
+++ b/pwnlib/util/proc.py
@@ -56,8 +56,6 @@ def pid_by_name(name):
         List of PIDs matching `name` sorted by lifetime, youngest to oldest.
 
     Example:
-        >>> 1 in pid_by_name('init')
-        True
         >>> os.getpid() in pid_by_name(name(os.getpid()))
         True
     """
@@ -83,8 +81,8 @@ def name(pid):
         Name of process as listed in ``/proc/<pid>/status``.
 
     Example:
-        >>> name(1)
-        'init'
+        >>> name(os.getpid()) == os.path.basename(sys.argv[0])
+        True
     """
     return psutil.Process(pid).name()
 


Test patch: