-
Notifications
You must be signed in to change notification settings - Fork 447
Open
Labels
Description
Hi,
I like to use your tool to organize all my scans. This is why, I often launch external tools from a term. I changed your code to realize a very useful function for me: "to copy the ip to the clipboard".
If you think, it could be interesting (and I assure you, it will) to add to your master. Here is the code:
- controller.py (you need to install pyperclip => pip install pyperclip)
When you click from the host, it will only copy the ip address
import pyperclip
....
def getContextMenuForHost(self, isChecked, showAll=True): # showAll exists because in some cases we only want to show host tools excluding portscans and 'mark as checked'
menu = QMenu()
self.nmapSubMenu = QMenu('Portscan')
actions = []
for a in self.settings.hostActions:
if "nmap" in a[ 1] or "unicornscan" in a[1]:
actions.append(self.nmapSubMenu.addAction(a[0]))
else:
actions.append(menu.addAction(a[0]))
if showAll:
actions.append(self.nmapSubMenu.addAction("Run nmap (staged)"))
menu.addMenu(self.nmapSubMenu)
menu.addSeparator()
if isChecked == 'True':
menu.addAction('Mark as unchecked')
else:
menu.addAction('Mark as checked')
# MODIFIED HERE #
menu.addAction('Copy to clipboard')
return menu, actions
def handleHostAction(self, ip, hostid, actions, action):
if action.text() == 'Mark as checked' or action.text() == 'Mark as unchecked':
self.logic.toggleHostCheckStatus(ip)
self.view.updateInterface()
return
# MODIFIED HERE #
if action.text() == 'Copy to clipboard':
pyperclip.copy(ip)
And the same thing, when you click on a port, it will copy the "ip:port"
def getContextMenuForServiceName(self, serviceName='*', menu=None):
if menu == None: # if no menu was given, create a new one
menu = QMenu()
# MODIFIED HERE #
menu.addAction("Copy to clipboard")
if serviceName == '*' or serviceName in self.settings.general_web_services.split(","):
....
def handleServiceNameAction(self, targets, actions, action, restoring=True):
# MODIFIED HERE #
if action.text() == 'Copy to clipboard':
for ip in targets:
pyperclip.copy('%s:%s' % (ip[0],ip[1]))
....
It will be very useful to add this functionality to the master.
Thanks a lot.