├── README.md ├── conf ├── rinetd ├── rinetd.conf └── rinetd.pid ├── rinted.jpg ├── rinted_running.jpg ├── templates └── index.html └── webserver.py /README.md: -------------------------------------------------------------------------------- 1 | # rinetdweb 2 | rinet代理web界面, 适用于Centos/Redhat系列系统,Debian或Other请自行测试
3 | # 使用方法:
4 | #在Linux系统输入下面的命令,一行一个:
5 | #安装依赖
6 | yum -y install gcc gcc-c++
7 | #下载rinetd
8 | wget https://boutell.com/rinetd/http/rinetd.tar.gz
9 | #解压
10 | tar -zxvf rinetd.tar.gz
11 | #创建手册目录
12 | mkdir -p /usr/man/man8
13 | #进入目录
14 | cd rinetd
15 | #编译安装
16 | make && make install
17 | #安装python-pip,uwsgi
18 | yum install python-pip python-devel uwsgi
19 | #安装web.py
20 | pip install web.py
21 |
22 | # 运行程序
23 | git clone https://github.com/xmapst/rinetdweb.git
24 | cd rinetdweb
25 | uwsgi --http 0.0.0.0:9000 -w webserver 26 | # 浏览器打开 27 | http://youripaddr:9000
28 | ![](https://github.com/xmapst/rinetdweb/blob/master/rinted.jpg)
29 | ![](https://github.com/xmapst/rinetdweb/blob/master/rinted_running.jpg) 30 | -------------------------------------------------------------------------------- /conf/rinetd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # chkconfig: 2345 90 10 3 | # description: rinetd Server 4 | 5 | EXEC=/usr/sbin/rinetd 6 | CONF=$1 7 | PID_FILE=/var/run/rinetd.pid 8 | NAME=Rinetd 9 | DESC="Rinetd Server" 10 | 11 | [ -f \$sysconfig ] && . \$sysconfig 12 | 13 | case "$2" in 14 | start) 15 | if [ -x "$PID_FILE" ]; then 16 | echo "$NAME is running ..." 17 | exit 0 18 | fi 19 | 20 | $EXEC -c $CONF 21 | 22 | echo -e "\e[1;32m$NAME is running\e[0m" 23 | ;; 24 | stop) 25 | if [ -f "$PID_FILE" ]; then 26 | kill `cat $PID_FILE` 27 | 28 | while [ -x "$PID_FILE" ] 29 | do 30 | echo "Waiting for $NAME to shutdown..." 31 | sleep 1 32 | done 33 | 34 | rm -f $PID_FILE 35 | fi 36 | 37 | echo -e "\e[1;31m$NAME stopped.\e[0m" 38 | ;; 39 | restart) 40 | $0 $CONF stop 41 | $0 $CONF start 42 | ;; 43 | status) 44 | if [ -f $PID_FILE ]; then 45 | echo "$NAME is running ..." 46 | else 47 | echo "$NAME stopped." 48 | fi 49 | ;; 50 | *) 51 | echo $"Usage: $0 {start|stop|restart|status}" 52 | exit 2 53 | ;; 54 | esac 55 | 56 | exit 0 57 | -------------------------------------------------------------------------------- /conf/rinetd.conf: -------------------------------------------------------------------------------- 1 | 0.0.0.0 7501 125.88.151.125 7501 2 | 0.0.0.0 7511 125.88.151.125 7511 3 | 0.0.0.0 7521 125.88.151.125 7521 4 | 0.0.0.0 7531 125.88.151.125 7531 5 | 0.0.0.0 9001 125.88.151.125 9001 6 | 0.0.0.0 9011 125.88.151.125 9011 7 | 0.0.0.0 9021 125.88.151.125 9021 8 | 0.0.0.0 9031 125.88.151.125 9031 9 | 0.0.0.0 801 35.236.131.97 801 10 | 0.0.0.0 8080 183.60.252.8 8080 11 | -------------------------------------------------------------------------------- /conf/rinetd.pid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmapst/rinetdweb/61cd183c04292ecc191beea323788af5c693497b/conf/rinetd.pid -------------------------------------------------------------------------------- /rinted.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmapst/rinetdweb/61cd183c04292ecc191beea323788af5c693497b/rinted.jpg -------------------------------------------------------------------------------- /rinted_running.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xmapst/rinetdweb/61cd183c04292ecc191beea323788af5c693497b/rinted_running.jpg -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | $def with(result, status, port_state, msg) 2 | 3 | 4 | 5 | Rinted端口转发 6 | 7 | 8 |

rinted端口转发

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | $for k,v in result.items(): 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 55 | 61 | 62 | 67 | 68 | 69 | 70 |
SocIPSocPortDesIPDecPort操作
 
ID已存在的记录
$k$v['SocIP']$v['SocPort']$v['DesIP']$v['DesPort']
 状态: 50 | $if status: 51 | $status 52 | $else: 53 |   54 | 56 | $if msg: 57 | $msg 58 | $else: 59 |   60 |
63 | 64 |   65 | 66 |
71 |  
72 | 73 | 74 | 75 | 76 | 77 | 84 | 85 |

正在运行的端口

78 |             $if port_state:
79 |                 $for line in port_state:
80 |                     $line
81 |             $else:
82 |                  
83 |             
86 | 87 | 88 | -------------------------------------------------------------------------------- /webserver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | # @Author : lijunye 5 | # @File : webserver.py 6 | # @Time : 2019/1/10 7 | # @Uptime : 8 | # @Version : 0.1 9 | # @Features : 10 | # @Desc : rinted端口转发 WEB界面操作 11 | """ 12 | 13 | import web 14 | import os 15 | import time 16 | import commands 17 | import fileinput 18 | import subprocess 19 | import shlex 20 | 21 | render = web.template.render('templates/') 22 | rinstate, rinetd_bin = commands.getstatusoutput('which rinetd') 23 | BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 24 | CONF = "conf/rinetd.conf" 25 | PID = """ps -elf |grep rinetd|grep -v grep |awk '{print $4}'""" 26 | 27 | if rinstate != 0: 28 | print("rinetd is not find") 29 | os._exit() 30 | 31 | urls = ( 32 | '/', 'Index', 33 | '/add', 'Add', 34 | '/del', 'Del', 35 | '/op(.*)', 'Operate' 36 | ) 37 | 38 | app = web.application(urls, globals()) 39 | 40 | def getConf(): 41 | i = 0 42 | result = {} 43 | with open( CONF, 'r') as fobj: 44 | lines = fobj.readlines() 45 | for line in lines: 46 | line = line.strip('\n') 47 | result[i] = line 48 | i += 1 49 | print line 50 | 51 | k = ['SocIP', 'SocPort', 'DesIP', 'DesPort'] 52 | for line in result.keys(): 53 | v = str(result[line]).split() 54 | result[line] = dict(zip(k, v)) 55 | return result 56 | 57 | def rinetd_state(): 58 | pid = commands.getoutput(PID) 59 | if pid == "": 60 | return "Rinetd已停止" 61 | else: 62 | return "Rinetd运行中" 63 | 64 | class Index(): 65 | def GET(self): 66 | result = getConf() 67 | port_state = commands.getoutput('netstat -lnt').split("\n") 68 | status = rinetd_state() 69 | return render.index(result, status, port_state, msg=None) 70 | 71 | class Add(): 72 | def POST(self): 73 | form = web.input() 74 | result = getConf() 75 | status = rinetd_state() 76 | port_state = commands.getoutput('netstat -lnt').split("\n") 77 | p = [] 78 | for i,n in enumerate(port_state): 79 | if i > 1: 80 | s = ' '.join(n.split()) 81 | p.append(s.split()[3].split(":")[-1]) 82 | if form['SocIP'] != "" and form['SocPort'] != "" and form['DesIP'] != "" and form['DesPort'] != "": 83 | #result = ' '.join(form.values()) 84 | for line in result.values(): 85 | if line['SocPort'] == form['SocPort'] or form['SocPort'] in p: 86 | msg = "端口已存在" 87 | return render.index(result, status, port_state, msg) 88 | 89 | new_result = "%s %s %s %s" % (form['SocIP'], form['SocPort'], form['DesIP'], form['DesPort']) 90 | with open(CONF, mode='a') as data: 91 | data.write(new_result.encode("utf-8") + '\n') 92 | msg = "添加成功" 93 | return render.index(result, status, port_state, msg) 94 | else: 95 | msg = "不允许为空" 96 | return render.index(result, status, port_state, msg) 97 | 98 | 99 | class Del(): 100 | def POST(self): 101 | form = web.input() 102 | result = getConf() 103 | status = rinetd_state() 104 | port_state = commands.getoutput('netstat -lnt').split("\n") 105 | lists = [] 106 | for line in result.values(): 107 | lists.append(line['SocPort']) 108 | if form['SocIP'] != "" and form['SocPort'] != "" and form['DesIP'] != "" and form['DesPort'] != "": 109 | with open( CONF, 'r') as fobj: 110 | lines = fobj.readlines() 111 | for line in lines: 112 | line = line.strip('\n') 113 | new_result = line.split(" ")[1] 114 | if form['SocPort'] in lists and form['SocPort'] == new_result: 115 | count = 0 116 | while count < len(lines): 117 | if len(lines[count]) > 2 and new_result == lines[count].split(" ")[1]: 118 | lines.pop(count) 119 | else: 120 | count += 1 121 | with open( CONF, 'w') as wobj: 122 | wobj.writelines(lines) 123 | print line 124 | msg = "删除成功" 125 | return render.index(result, status, port_state, msg) 126 | else: 127 | msg = "记录不存在" 128 | return render.index(result, status, port_state, msg) 129 | 130 | class Operate(): 131 | def POST(self,operate=None): 132 | form = web.input() 133 | result = getConf() 134 | if form['pm'] == 'start': 135 | pid = commands.getoutput(PID) 136 | if pid != "": 137 | raise web.seeother('/') 138 | stats = subprocess.Popen( rinetd_bin + ' -c ' + CONF + ' &' , shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) 139 | time.sleep(0.3) 140 | raise web.seeother('/') 141 | elif form['pm'] == 'stop': 142 | pid = commands.getoutput(PID) 143 | if pid == "": 144 | raise web.seeother('/') 145 | commands.getstatusoutput('killall rinetd') 146 | raise web.seeother('/') 147 | elif form['pm'] == 'reload': 148 | pid = commands.getoutput(PID) 149 | if pid == "": 150 | raise web.seeother('/') 151 | commands.getstatusoutput("kill -1 `ps -elf |grep rinetd|grep -v grep |awk '{print $4}'`") 152 | time.sleep(0.3) 153 | raise web.seeother('/') 154 | 155 | application = app.wsgifunc() 156 | --------------------------------------------------------------------------------