Skip to content

Commit

Permalink
Add ability to run arbitrary commands on IP/DNS config
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
  • Loading branch information
champtar committed Jul 29, 2019
1 parent bdb2f36 commit 5925a9a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ define Package/phantap
DEPENDS:=+ebtables +tcpdump +ip-full +kmod-br-netfilter +kmod-ebtables-ipv4
endef

define Package/phantap/conffiles
/etc/config/phantap
endef

define Package/phantap/description
PhanTap or Phantom tap is a small set of scripts that allow you to setup a network tap
that automatically impersonnate a victim device, allowing you to access internet using
Expand All @@ -48,6 +52,8 @@ define Build/Prepare
endef

define Package/phantap/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/etc/config/phantap $(1)/etc/config/phantap
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DATA) ./files/etc/hotplug.d/iface/00-phantap $(1)/etc/hotplug.d/iface/00-phantap
$(INSTALL_DIR) $(1)/etc/hotplug.d/net
Expand Down
5 changes: 5 additions & 0 deletions files/etc/config/phantap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

config phantap 'main'
#list onnetconfig '/etc/init.d/openvpn restart'
#list ondnsconfig '/etc/init.d/myservice restart'

13 changes: 12 additions & 1 deletion files/usr/bin/phantap
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh

. /lib/functions.sh
. /lib/functions/network.sh

INTF=phantap
Expand Down Expand Up @@ -66,6 +67,14 @@ mv /tmp/phantap.firewall.$$ /tmp/phantap.firewall
ebtables -t filter -A phantap-drop -j DROP
/etc/init.d/firewall reload

handle_onconfig() {
/bin/sh -c "$1" || echo "'$1' failed"
}

config_load phantap
# Run all commands in onnetconfig list
config_list_foreach main onnetconfig handle_onconfig

while true; do
# uses tcpdump to grab dns traffic
echo "Listening to traffic for dns config ..."
Expand All @@ -86,6 +95,8 @@ done

echo "nameserver $dns_ip" > /tmp/resolv.conf

# Run all commands in ondnsconfig list
config_list_foreach main ondnsconfig handle_onconfig

echo "setup done, you now have access to internet"

# restart openvpn

0 comments on commit 5925a9a

Please sign in to comment.