Esempio n. 1
0
    def _download_raw(self, remote, local):
        self._initialize_sftp()
        total, _ = self.run_simple('wc -c "$(echo %s|base64 -d)"' %
                                   pwn.b64(remote))
        total = pwn.size(int(total.split()[0]))

        if not self.silent:
            pwn.log.waitfor('Downloading %s' % remote)

        def update(has, _total):
            if not self.silent:
                pwn.log.status("%s/%s" % (pwn.size(has), total))

        if self._supports_sftp:
            self._sftp.get(remote, local, update)
        else:
            dat = ''
            s = self.run('cat "$(echo %s|base64 -d)"' % pwn.b64(remote),
                         silent=True)
            while s.connected():
                update(len(dat), 0)
                dat += s.recv()
            pwn.write(local, dat)
        if not self.silent:
            pwn.log.succeeded()
Esempio n. 2
0
    def _get_fingerprint(self, remote):
        dat, status = self.run_simple('sha256sum "$(echo %s|base64 -d)"' % pwn.b64(remote))
        if status == 0:
            return dat.split()[0]

        dat, status = self.run_simple('sha1sum "$(echo %s|base64 -d)"' % pwn.b64(remote))
        if status == 0:
            return dat.split()[0]

        dat, status = self.run_simple('md5sum "$(echo %s|base64 -d)"' % pwn.b64(remote))
        if status == 0:
            return dat.split()[0]

        return None
Esempio n. 3
0
    def upload(self, remote = None, local = None, raw = None):
        '''Uploads a file to the remote server.

        If remote is set to None, then the remote filename is inferred from the
        local filename.

        If raw is None, then the file specified by local is uploaded.
        Otherwise the data in the raw variable is uploaded instead.'''

        self._initialize_sftp()

        if remote == None:
            remote = os.path.normpath(local)
            remote = os.path.basename(remote)

        if self._supports_sftp:
            if raw == None:
                self._sftp.put(local, remote)
            else:
                f = self._sftp.open(remote, 'wb')
                f.write(raw)
                f.close()
        else:
            if raw == None:
                raw = pwn.read(local)
            s = self.run('cat>"$(echo %s|base64 -d)"' % pwn.b64(remote), silent = True)
            s.send(raw)
            s._channel.shutdown_write()
            s.recvall()
Esempio n. 4
0
    def upload(self, remote=None, local=None, raw=None):
        '''Uploads a file to the remote server.

        If remote is set to None, then the remote filename is inferred from the
        local filename.

        If raw is None, then the file specified by local is uploaded.
        Otherwise the data in the raw variable is uploaded instead.'''

        self._initialize_sftp()

        if remote == None:
            remote = os.path.normpath(local)
            remote = os.path.basename(remote)

        if self._supports_sftp:
            if raw == None:
                self._sftp.put(local, remote)
            else:
                f = self._sftp.open(remote, 'wb')
                f.write(raw)
                f.close()
        else:
            if raw == None:
                raw = pwn.read(local)
            s = self.run('cat>"$(echo %s|base64 -d)"' % pwn.b64(remote),
                         silent=True)
            s.send(raw)
            s._channel.shutdown_write()
            s.recvall()
Esempio n. 5
0
    def _libs_remote(self, remote):
        '''Return a dictionary of the libraries used by a remote file.'''
        dat, status = self.run_simple('ldd "$(echo %s|base64 -d)"' % pwn.b64(remote))
        if status != 0:
            pwn.log.warning('Unable to find libraries for "%s"' % remote)
            return {}

        return pwn.parse_ldd_output(dat)
Esempio n. 6
0
    def _get_fingerprint(self, remote):
        dat, status = self.run_simple('sha256sum "$(echo %s|base64 -d)"' %
                                      pwn.b64(remote))
        if status == 0:
            return dat.split()[0]

        dat, status = self.run_simple('sha1sum "$(echo %s|base64 -d)"' %
                                      pwn.b64(remote))
        if status == 0:
            return dat.split()[0]

        dat, status = self.run_simple('md5sum "$(echo %s|base64 -d)"' %
                                      pwn.b64(remote))
        if status == 0:
            return dat.split()[0]

        return None
Esempio n. 7
0
    def _libs_remote(self, remote):
        '''Return a dictionary of the libraries used by a remote file.'''
        dat, status = self.run_simple('ldd "$(echo %s|base64 -d)"' %
                                      pwn.b64(remote))
        if status != 0:
            pwn.log.warning('Unable to find libraries for "%s"' % remote)
            return {}

        return pwn.parse_ldd_output(dat)
Esempio n. 8
0
    def _download_raw(self, remote, local):
        self._initialize_sftp()
        total, _ = self.run_simple('wc -c "$(echo %s|base64 -d)"' % pwn.b64(remote))
        total = pwn.size(int(total.split()[0]))

        if not self.silent:
            pwn.log.waitfor('Downloading %s' % remote)

        def update(has, _total):
            if not self.silent:
                pwn.log.status("%s/%s" % (pwn.size(has), total))

        if self._supports_sftp:
            self._sftp.get(remote, local, update)
        else:
            dat = ''
            s = self.run('cat "$(echo %s|base64 -d)"' % pwn.b64(remote), silent = True)
            while s.connected():
                update(len(dat), 0)
                dat += s.recv()
            pwn.write(local, dat)
        if not self.silent:
            pwn.log.succeeded()
Esempio n. 9
0
if __name__ == '__main__':
    from Crypto.Util import number
    import requests

    if len(sys.argv) < 2 or 3 < len(sys.argv):
        print('- Indirect and encrypted poke through pastebins -')
        print('Usage: %s password [filename]' % sys.argv[0])
        sys.exit(1)

    password = sys.argv[1]
    filename = sys.argv[2] if len(sys.argv) == 3 else None

    data = read(filename) if filename is not None else sys.stdin.read()

    cipher = Encryption(password)
    upload_data = b64(cipher.encrypt(data))

    try:
        upload = {'public': False, 'files': {'data': {'content': upload_data}}}
        req = requests.post('https://api.github.com/gists',
                            data=json.dumps(upload))
    except Exception as e:
        print('Unable to upload data to Github.')
        print(str(e))
        sys.exit(1)

    if req.status_code != 201:
        print('Unable to upload to github, debug information follows')
        print(req.text)
        sys.exit(1)
Esempio n. 10
0
if __name__ == '__main__':
    from Crypto.Util import number
    import requests

    if len(sys.argv) < 2 or 3 < len(sys.argv):
        print('- Indirect and encrypted poke through pastebins -')
        print('Usage: %s password [filename]' % sys.argv[0])
        sys.exit(1)

    password = sys.argv[1]
    filename = sys.argv[2] if len(sys.argv) == 3 else None

    data = read(filename) if filename is not None else sys.stdin.read()

    cipher = Encryption(password)
    upload_data = b64(cipher.encrypt(data))

    try:
        upload = {'public':False, 'files':{'data':{'content':upload_data}}}
        req = requests.post('https://api.github.com/gists', data=json.dumps(upload))
    except Exception as e:
        print('Unable to upload data to Github.')
        print(str(e))
        sys.exit(1)

    if req.status_code != 201:
        print('Unable to upload to github, debug information follows')
        print(req.text)
        sys.exit(1)

    try: