From 6c0c68dd2e6c42c29074f7ac60cf258a4b972926 Mon Sep 17 00:00:00 2001 From: BrainwreckedTech Date: Fri, 19 Jun 2020 05:20:20 -0400 Subject: [PATCH] Added sshproxy --- README.md | 3 + sshproxy | 146 ++++++++++++++++++++++++++++++++++++++++++++ sshproxy-active.png | Bin 0 -> 4673 bytes sshproxy-unused.png | Bin 0 -> 4930 bytes 4 files changed, 149 insertions(+) create mode 100755 sshproxy create mode 100644 sshproxy-active.png create mode 100644 sshproxy-unused.png diff --git a/README.md b/README.md index 3552263..40b277d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ mkminchroot ssh-multirun : Runs the same command on multiple machines +ssh-proxy +: Systray applet to enabled/disable an SSH proxy tunnel + ssh-reboot : Reboots a machine via `ssh` diff --git a/sshproxy b/sshproxy new file mode 100755 index 0000000..199a9e4 --- /dev/null +++ b/sshproxy @@ -0,0 +1,146 @@ +#!/usr/bin/env python + +# ©2020 Shzublox, BrainreckedTech +# Licensed under the GPL v3 + +import subprocess, wx, wx.adv + +PROGRAM_NAME = 'SSH Proxy' +STOPPED_ICON = "/usr/share/pixmaps/sshproxy-unused.png" +STARTED_ICON = "/usr/share/pixmaps/sshproxy-active.png" +DEFAULT_PORT = "8080" +DEFAULT_ADDR = "proxy" + +def create_menu_item(menu, label, func): + item = wx.MenuItem(menu, -1, label) + menu.Bind(wx.EVT_MENU, func, id=item.GetId()) + menu.Append(item) + return item + +class MyTaskBarIcon(wx.adv.TaskBarIcon): + def __init__(self, frame): + wx.adv.TaskBarIcon.__init__(self) + self.frame = frame + + self.SetIcon(self.frame.stopped_icon, PROGRAM_NAME) + self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.leftclicked) + + def CreatePopupMenu(self): + menu = wx.Menu() + create_menu_item(menu, 'Configure', self.configure) + create_menu_item(menu, 'Exit', self.frame.close) + return menu + + def leftclicked(self, event): + if self.frame.ssh: + self.frame.on_stop(None) + else: + self.frame.on_start(None) + + def configure(self, event): + self.frame.Show() + self.frame.Restore() + +class MyFrame(wx.Frame): + def __init__(self, parent, stopped_icon, started_icon): + wx.Frame.__init__(self, parent, title=PROGRAM_NAME, + style = wx.DEFAULT_FRAME_STYLE & + ~(wx.RESIZE_BORDER | wx.MINIMIZE_BOX + | wx.MAXIMIZE_BOX | wx.CLOSE_BOX)) + + self.ssh = None + self.stopped_icon = stopped_icon + self.started_icon = started_icon + + self.SetIcon(stopped_icon) + + self.tray = MyTaskBarIcon(self) + self.Bind(wx.EVT_ICONIZE, self.iconize) + self.Bind(wx.EVT_CLOSE, self.close) + + panel_sizer = wx.FlexGridSizer(cols=1) + text_sizer = wx.FlexGridSizer(cols=2) + button_sizer = wx.BoxSizer() + panel = wx.Panel(self) + + portlabel = wx.StaticText(panel, label="Port: ") + self.portbox = wx.TextCtrl(panel, value=DEFAULT_PORT, size=(300, -1)) + + remotelabel = wx.StaticText(panel, label="Remote: ") + self.remotebox = wx.TextCtrl(panel, value=DEFAULT_ADDR, size=(300, -1)) + + self.startbutton = wx.Button(panel, label="Start") + self.stopbutton = wx.Button(panel, label="Stop") + + self.stopbutton.Disable() + + text_sizer.Add(portlabel, 1, wx.EXPAND) + text_sizer.Add(self.portbox, 1, wx.EXPAND) + text_sizer.Add(remotelabel, 1, wx.EXPAND) + text_sizer.Add(self.remotebox, 1, wx.EXPAND) + text_sizer.Fit(self) + + button_sizer.Add(self.startbutton, 1, wx.EXPAND) + button_sizer.Add(self.stopbutton, 1, wx.EXPAND) + button_sizer.Fit(self) + + panel_sizer.Add(text_sizer, 1, wx.EXPAND) + panel_sizer.Add(button_sizer, 1, wx.EXPAND) + panel_sizer.Fit(self) + + self.startbutton.Bind(wx.EVT_BUTTON, self.on_start) + self.stopbutton.Bind(wx.EVT_BUTTON, self.on_stop) + + self.SetSizer(panel_sizer) + + def close(self, event): + self.tray.RemoveIcon() + self.tray.Destroy() + self.Destroy() + + def iconize(self, event): + if self.IsIconized(): + self.Show(False) + self.Restore() + + def on_start(self, event): + if self.portbox.GetValue() == "" or self.remotebox.GetValue() == "": + return + + self.startbutton.Disable() + self.stopbutton.Enable() + self.tray.SetIcon(self.started_icon) + self.ssh = subprocess.Popen(["ssh", "-ND", + "%s" % self.portbox.GetValue(), + "%s" % self.remotebox.GetValue()], + stdin = subprocess.PIPE, + stdout = subprocess.PIPE, + stderr = subprocess.PIPE, + universal_newlines = True) + + def on_stop(self, event): + self.startbutton.Enable() + self.stopbutton.Disable() + self.tray.SetIcon(self.stopped_icon) + if self.ssh: + self.ssh.terminate() + self.ssh = None + +def main(): + app = wx.App(False) + + image = wx.Image(STOPPED_ICON, wx.BITMAP_TYPE_ANY) + bmp = wx.Bitmap(image) + stopped_icon = wx.Icon() + stopped_icon.CopyFromBitmap(bmp) + + image = wx.Image(STARTED_ICON, wx.BITMAP_TYPE_ANY) + bmp = wx.Bitmap(image) + started_icon = wx.Icon() + started_icon.CopyFromBitmap(bmp) + + frame = MyFrame(None, stopped_icon, started_icon) + app.MainLoop() + +if __name__ == "__main__": + main() diff --git a/sshproxy-active.png b/sshproxy-active.png new file mode 100644 index 0000000000000000000000000000000000000000..004d4bc00a7bd1d71754a37d5fc046caaea78e9d GIT binary patch literal 4673 zcmV-H629$;P)7BN*O=y6%JU znDK%Qs9I_@^*_v+IcJPfcYms??&>N)rBdw_=@6WrVxDwYK>PLIEnuF}XsIKkfSfWE zoeVZ1pwHm;mW42DA-c+FG}qBmKu$)6$9)Ed4D|N;|Da1t$y7&90SVb!v~$?L1rmTe z2md^xFKS7Cxu2?#z*xb4U%?Kyxl#LSh5Q=8xsIq>kYM7A9CpaSpbQwlyIQ!gG=5Y- zRE-b30UkJ58VgWzrhurL2u3%99l8NS19kQ9u+7$2xT@qJVfT z!|A|+hXA@YE|HVAA_|DNU>tXbp;klzQ83hsC?E=kXW#Ket%w3rlVYBeO4Uh|6bIRq9HuU|$%VGz|^_DBQpkn=@Uu6^YY33%+Y27#k1K zF`Nz*5S6SS%jwv4T1a(Pgohe~s3c>KPKNv?tV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wp`TiM&zoPigKHkP4L1Xx@T3Z+gH^pk)i@MgdVd zfh30cLZGz4*5o#%f(#mi`21$#bYOu*Do?8->v5)ls1%g#fTT>x_|)b{0r3hH9>UYz zu3r^U6cAOd6T*`okSBg6InorAT%P27=#o@W_OKpjA>a8>KpGE<9ZD68Q|qCC1gV%O zoua)N57c@nAgWJ5A)xQRs>x|v4+W&zptOr-n;5zR<{ z&QebG)La2Ml}RnR^JPGnr*a`m0Xgx2K8GDLuy=bk1G=%4T~_Bhv?Sn4 zEr$Yf>acWIuzdi30Ne&>$-rMR%v56zl}e>jsigFO;)|;Exz~go00000NkvXXu0mjf DcG1fY literal 0 HcmV?d00001 diff --git a/sshproxy-unused.png b/sshproxy-unused.png new file mode 100644 index 0000000000000000000000000000000000000000..0bd6d1e1d6141774b00d72e4c61a97ae767f7d4d GIT binary patch literal 4930 zcmV-I6TR$-P)u{lH$c@oGA`TfpugatY!h3cYJ<%LX6Hy?wi(FC4p<9J6_blZh8GcxTo;kd z>|_N+XGg+jb|fhCMS`<+0rT3yfD*;!4*=6M^JdWBU`yH(LCkyaGu{1Oziz-}GCe5T z5bT~#7*ntbV0tXc+(yO#*<~o&3-}>{o`|%5vk-_$1JTj3BvTtL17v3u6FmV2 zBIvI3?;UwC6dBvd86b7G7Oe!n=Yb(a+ME7-lhJdtB%j?+Q=PzA!XGZ-2lu&A>uQPQ z4S+oxQL`Ymi7yiPfdKt1V0`UrVSgyNGC)j~54<7L*IyZ&#UjrP5K|Sw=q%s|xqx8- zy8%*FjTm)-WVr5*lvxo2#K6c|yKY4ckbo7FeGeHx&?#?)?6ws#K!OEhyE6>4A_j$+T1Pl>t($Sl=@P0s1G5S_X(I!vJ$qSMWsS zCZEgzF>R*^?o1a9j>%}RiRd7ZM;z39{!F>*XUKeyB(VK;S(0;-e`+#17>d7`KxQw9 ze-_}o03NZ{=_huQUXX_5`Nruc#MFUj_hrxy$q%8V$&;9jq@IQ543J_WIVA98CNIe= zz@0sm&JhzmFSrb9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