Skip to content

Instantly share code, notes, and snippets.

@imrehg
Last active April 10, 2018 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imrehg/a0fdc0e09b76febe38a8eb9792d63ef8 to your computer and use it in GitHub Desktop.
Save imrehg/a0fdc0e09b76febe38a8eb9792d63ef8 to your computer and use it in GitHub Desktop.
Proxy testing for resinOS

HTTP Proxy Test

Test

1) Proxy setup

Connect to the target device's host OS, and create the system-proxy directory:

mkdir -p /mnt/boot/system-proxy/

On the target device (ssh into the hostOS) create this file and replace the with the one of the host which will have the proxy server (your development machine for example):

cat <<'EOF'>> /mnt/boot/system-proxy/redsocks.conf
base {
log_debug = off;
log_info = on;
log = stderr;
daemon = off;
redirector = iptables;
}
redsocks {
type = http-connect;
ip = <SERVER IP>;
port = 8123;
local_ip = 127.0.0.1;
local_port = 12345;
}
EOF

Finally, reboot the device under test with reboot.

Note: for QEMU images, you have to use the IP of the host (and you get it by running route and checking for the gateway), for example:

root@087ce64:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.2.2        0.0.0.0         UG    100    0        0 enp0s3

here it would be that you need to use 10.0.2.2.

For physical devices, you can use your development machine's local network IP, or <hostname>.local if you are using Avahi. (Note that ip = can take both an IP address and hostname).

2) Proxying

On a server host machine (your development machine for example) located in the same network, install the glider.

Start a mixed SOCKS/HTTP proxy with running:

glider -listen :8123 -verbose

Wait until the device appears online in the dashboard and then hit CTRL+C to stop the above command.

3) Clean-up

  • a - On the server (your development machine for example), restart the proxy:
glider -listen :8123 -verbose

After starting the proxy, the device should appear online, allowing you to ssh to it and continue with the following step.

  • b - Execute on the target device (on the hostOS) to remove the proxy settings:
rm -rf /mnt/boot/system-proxy && reboot

You should now stop the proxy on your development machine.

Result

1) Proxy setup

The device should reboot and remain offline in the dashboard.

2) Proxying

Once the proxy has been started on the development machine, the device should appear as online in the dashboard.

In the proxy logs should see lines like:

2018/04/10 10:48:01 proxy-https 127.0.0.1:36624 <-> 159.122.19.148:80

where the key is seeing proxy-https to signal that the connection is over HTTP(S).

When pressing CTRL+C, the device should go offline.

3) Clean-up

  • a - Once the proxy has been re-started, the device should appear as online in the dashboard.
  • b - The device should reboot and then appear online in the dashboard once booted up.

SOCKS Proxy Test

Test

1) Proxy setup

Connect to the target device's host OS, and create the system-proxy directory:

mkdir -p /mnt/boot/system-proxy/

On the target device (ssh into the hostOS) create this file and replace the with the one of the host which will have the proxy server (your development machine for example):

cat <<'EOF'>> /mnt/boot/system-proxy/redsocks.conf
base {
log_debug = off;
log_info = on;
log = stderr;
daemon = off;
redirector = iptables;
}
redsocks {
type = socks5;
ip = <SERVER IP>;
port = 8123;
local_ip = 127.0.0.1;
local_port = 12345;
}
EOF

Finally, reboot the device under test with reboot.

Note: for QEMU images, you have to use the IP of the host (and you get it by running route and checking for the gateway), for example:

root@087ce64:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.2.2        0.0.0.0         UG    100    0        0 enp0s3

here it would be that you need to use 10.0.2.2.

For physical devices, you can use your development machine's local network IP, or <hostname>.local if you are using Avahi. (Note that ip = can take both an IP address and hostname).

2) Proxying

On a server host machine (your development machine for example) located in the same network, install the glider.

Start a mixed SOCKS/HTTP proxy with running:

glider -listen :8123 -verbose

Wait until the device appears online in the dashboard and then hit CTRL+C to stop the above command.

3) Clean-up

  • a - On the server (your development machine for example), restart the proxy:
glider -listen :8123 -verbose

After starting the proxy, the device should appear online, allowing you to ssh to it and continue with the following step.

  • b - Execute on the target device (on the hostOS) to remove the proxy settings:
rm -rf /mnt/boot/system-proxy && reboot

You should now stop the proxy on your development machine.

Result

1) Proxy setup

The device should reboot and remain offline in the dashboard.

2) Proxying

Once the proxy has been started on the development machine, the device should appear as online in the dashboard.

In the proxy logs should see lines like:

2018/04/10 10:33:58 proxy-socks5 127.0.0.1:34906 <-> 54.210.236.83:443

where the key is seeing proxy-socks5 to signal that the connection is SOCKS.

When pressing CTRL+C, the device should go offline.

3) Clean-up

  • a - Once the proxy has been re-started, the device should appear as online in the dashboard.
  • b - The device should reboot and then appear online in the dashboard once booted up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment