0

I am trying to make a hacking tool in python and I need to run a PowerShell command (ping) but I don't want the "Reply from bytes=32 TTL=128" to appear.

import subprocess
ip_check = input('What IP would you....: ')
subprocess.call('powershell.exe ping ' + ip_check, shell=True)
Xenoy
  • 67
  • 1
  • 8

1 Answers1

0

You can add >$null 2>&1 at the end of the command:

import subprocess
ip_check = input('What IP would you....: ')
subprocess.call('powershell.exe ping >$null 2>&1' + ip_check, shell=True)
Wasif
  • 14,755
  • 3
  • 14
  • 34
  • Do you know how to save the initial command respons as a variable and hide it at the same time (sorry for not specifying that in the post)? – Xenoy Nov 04 '20 at 16:01
  • Do you mean us a Python var or a PS var? In a PowerShell proper instance , you just do this... ($PingCall = powershell.exe ping 127.0.0.1) >$null 2>&1 then look at $PingCall. In an external session (cmd, python, et al), that is the catch22. you'd have to tell that external session to catch stdout stuff since the above would only exist in the PS instance. So, maybe this, https://stackoverflow.com/questions/20140137/passing-variables-to-subprocess-popen will assist. – postanote Nov 04 '20 at 23:56