mazen160 / shennina

Automating Host Exploitation with AI
https://mazinahmed.net/blog/shennina-exploitation-framework/
483 stars 94 forks source link

[MSFRPC] Error connecting to MSFRPC Server #3

Closed dale915 closed 1 year ago

dale915 commented 1 year ago

Hi everyone,

How are you doing ?

I'm facing this issues in part 3.1 Initializing Exploits tree. Here is what I get when I run ./shennina.py --initialize-exploits-tree :

Screen Capture_select-area_20221201182216

Here is my config files :

!/usr/bin/env python3

import json import os from pymetasploit3.msfrpc import MsfRpcClient

Base config

PROJECT_PATH = os.path.dirname(os.path.abspath(file)) SCANS_PATH = PROJECT_PATH + "/.scans/" REPORTS_PATH = PROJECT_PATH + "/reports/"

Second brain configuration

SUPERVISOD_CSV_FILE = 'data/exploits.csv' SECOND_BRAIN_NAME = 'second_brain'

if not os.path.exists(SCANS_PATH): os.mkdir(SCANS_PATH) if not os.path.exists(REPORTS_PATH): os.mkdir(REPORTS_PATH)

EXPLOITS_TREE_PATH = PROJECT_PATH + "/data/" + "exploits_tree.json"

EXFILTRATION_SERVER = "172.17.0.1:8040" MAX_TESTING_THREADS = 10 SCANNING_THROUGH_TEST = False TTL_FOR_EXPLOIT_VALIDATION = 15.0

TODO: remove these lines and use config.EXPLOITS_TREE instead

SERVICE_LIST = 'openssh@dav@login@rpc@php@joomla@http@rmiregistry@krb524@x11@java@bind@domain@tcpwrapped@drupal@postfix@apache@vsftpd@proftpd@telnet@irc@jetty@nginx@unix@tikiwiki@postgresql@ftp@ajp13@vnc@smtp@sambasmbd@upnp@ldap@mysql@phpbb@ubuntu@webmin@samba@oscommerce@ms-wbt-server@exec@rpcbind@moodle@mediawiki@python@phpmyadmin@shell@wordpress@ssh@sugarcrm@netbios-ssn@tomcat@linuxtelnetd' OS_LIST = 'fortinet@windows@unix@solaris@osx@netware@linux@irix@hpux@freebsd@firefox@dialup@bsdi@apple_ios@android@aix@unknown'

Cache Search Results

CACHED_SEARCH_RESULTS = {}

Exploits Tree & Array

EXPLOITS_TREE = [] EXPLOITS_ARRAY = []

Functions

def getClient(): MSFRPC_CONFIG = open(PROJECT_PATH + "/config/" + "msfrpc-config.json")

MSFRPC_CONFIG = json.loads(MSFRPC_CONFIG.read())
client = None
try:
    client = MsfRpcClient(MSFRPC_CONFIG["password"],
                          user=MSFRPC_CONFIG["user"],
                          host=MSFRPC_CONFIG["host"],
                          port=MSFRPC_CONFIG["port"],
                          ssl=MSFRPC_CONFIG["ssl"])
except Exception:
    pass

return client

def loadExploitsTree(detailed=True): exploits_tree = json.loads(open(EXPLOITS_TREE_PATH, "r").read()) if detailed: return exploitstree return [['exploit'] for _ in exploits_tree]

{ "password": "password", "user": "username", "host": "127.0.0.1", "port": 55553, "ssl": false }

Can anybody help fix this ? Or give more explanation about the issue I'm facing ?

Thanks.

alexiof1982 commented 1 year ago

Hi,

I also had this issue and changed ssl=false in the file "run-msfrpc.py"

image

It looks like your metasploit should already turn it off but i had to change it in both places.

Good luck

Alex

alexiof1982 commented 1 year ago

oh and also you have to run Metasploit at least once to initialize the database, otherwise you will still get this error.

Alex

dale915 commented 1 year ago

Hi,

I also had this issue and changed ssl=false in the file "run-msfrpc.py"

image

It looks like your metasploit should already turn it off but i had to change it in both places.

Good luck

Alex

Hi Alex,

Thanks for your response.

I changed the ssl to false ins run-msfrpc.py but It didn't work.

Maybe your second comment but running Metasploit to initialize the database is running the run-msfrpc.py script right ?

Thanks. Dale.

alexiof1982 commented 1 year ago

Hi Dale,

For me on Kali Linux if you run that script (run-msfrpc.py) it still doesn't initialize the database so i had to run Metasploit separately for it to run its a initial config on the database. After doing that and turning off SSL Shennina could connect for me. Hope it helps you.

Alex

alexiof1982 commented 1 year ago

Hi Dale,

Just remembered another thing i tried. Didn't use the run-msfrpc.py script. Ran Metasploit, in the msf6> load msgrpc - copied the details into msfrpc-config.json that it produces. As i recall the first time I did that Shennina could connect. Subsequent times i used the script

image

dale915 commented 1 year ago

Been able to do all what you said. It seems to work but I get this error now :

Screen Capture_select-area_20221211055635

It looks like I didn't set well my exfiltration server. I wanted it to be my own computer so I can test shennina.

Do you have an idea how I can get that running properly. I didn't get well this concept of exfiltration server till now.

Thanks. Dale.

dale915 commented 1 year ago

When I run the script "./exfiltration-server/run-server.sh" I get this :

Screen Capture_select-area_20221211060429

I

changed EXFILTRATION_SERVER (in config.py) from 172.17.0.0.1:8040 to 127.0.0.1:44444.

but I think there is something going wrong with that part.

alexiof1982 commented 1 year ago

Looks like you need to fix your docker installation i think. I also have difficulty connecting to the exfiltration server currently. I will work on it. The process i followed was to install the docker engine then docker desktop. Seems like you need to do something like that.

I used these 2 guides

https://www.kali.org/docs/containers/installing-docker-on-kali/

https://docs.docker.com/desktop/install/linux-install/

Good luck bud. Let me know how you get on.

Alex

dale915 commented 1 year ago

Looks like you need to fix your docker installation i think. I also have difficulty connecting to the exfiltration server currently. I will work on it. The process i followed was to install the docker engine then docker desktop. Seems like you need to do something like that.

I used these 2 guides

https://www.kali.org/docs/containers/installing-docker-on-kali/

https://docs.docker.com/desktop/install/linux-install/

Good luck bud. Let me know how you get on.

Alex

Thanks Alex I got everything working now.

I needed to recheck my docker knowledge.

Thanks a lot :).