Skip to content

Instantly share code, notes, and snippets.

@andresriancho
Created March 30, 2014 14:38
Show Gist options
  • Select an option

  • Save andresriancho/9873639 to your computer and use it in GitHub Desktop.

Select an option

Save andresriancho/9873639 to your computer and use it in GitHub Desktop.
Collect system information to report w3af bug
#!/usr/bin/env python
import subprocess
import sys
def get_platform():
import platform
curr_platform = platform.system().lower()
distro = platform.dist()
release = platform.release()
return 'System: %s - Distribution: %s - Release: %s\n' % (curr_platform, distro, release)
COMMANDS = (
('Operating system', get_platform),
('Kernel version', 'uname -a'),
('Python version', 'python --version'),
('pip version', 'pip --version'),
('pip freeze', 'pip freeze'),
('Package list', 'dpkg -l'),
)
def generate_debugging_info():
out = file('/tmp/w3af-sysinfo.txt', 'w')
exit_code = 0
for name, cmd in COMMANDS:
if hasattr(cmd, '__call__'):
try:
cmd_output = cmd()
except:
exit_code = 1
else:
try:
cmd_output = subprocess.check_output(cmd, shell=True)
except subprocess.CalledProcessError:
exit_code = 1
out.write('%s\n' % name)
out.write('=' * len(name) + '\n')
out.write(cmd_output)
out.write('\n')
out.close()
return exit_code
if __name__ == '__main__':
sys.exit(generate_debugging_info())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment