Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy to clipboard #60

Open
AlessandroZ opened this issue Jun 24, 2016 · 1 comment
Open

Copy to clipboard #60

AlessandroZ opened this issue Jun 24, 2016 · 1 comment

Comments

@AlessandroZ
Copy link

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.

@xpelican
Copy link

Hello, are you considering merging this enhancement by @AlessandroZ into the master branch? It works very well and is super useful, for reasons they've already mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants