基于jquery的独立端口敲门人 [英] jquery-based standalone port knocker

查看:97
本文介绍了基于jquery的独立端口敲门人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个小项目,需要为团队成员提供一种替代方法,以使其端口挂接非生产服务器并打开端口22以进行SSH流量(访问会在10分钟后再次关闭).由于某些敲门方法不适用于不同设备上的不同用户,因此我们需要创建一个万不得已的敲门客户端",可以将其作为独立的网页打开,并启动敲门序列.当然,出于安全原因,永远不要将该文件放在Web服务器上.

I am working on a small project and need to provide an alternative method for my team members to port knock on a non-production server and open port 22 for SSH traffic (access closes again after 10 minutes). As some methods of knocking don't work for different users on different devices, we needed to create a 'knock client of last resort' that can be opened as a stand-alone web page and initiate the knock sequence. Of course this file would NEVER be put on a web server for security reasons.

我是jQuery,javascript和CSS的新手,但能够使它正常工作.但是,它不适用于所有浏览器,有时如果它不再在特定计算机上运行,​​我们有时必须重新启动.

I'm new to jQuery, javascript, and CSS, but was able to get this to work. However, it doesn't work in all browsers, and sometimes we have to reboot if it is no longer working on a particular machine.

经过大量搜索,我真的不确定如何在保持单个html文件中包含所有功能的同时改进代码.我非常感谢您的投入.

After a lot of searching, I’m really not sure how to improve my code while keeping all the functionality contained within a single html file. I would really appreciate some input.

<!DOCTYPE HTML>
<html>
<head>
<title>Gain Access- Beta version 1.0</title>
<style>
* {
    font-family: Verdana, Arial, Sans-Serif;
}
#top{
    margin-left:80px;
}
#heading {
    margin-left: 0px;
    font-size:22px;
    font-weight:bold;
}
#subhead {
    margin-left: 10px;
    font-size:12px;
}
button {
    font-size:16px;
    margin-left:100px;
}
#button {
    font-size: 12px;
    font-family: Verdana, Arial, Sans-Serif;
    position: absolute;
    margin-left: 100px;
    margin-top: 50px;
}
#status {
    margin-left:90px;
    margin-top: 80px;
    position: absolute;
    font-size:16px;
    font-weight:bold;
}
#knocks {
    margin-left:110px;
    margin-top: 100px;
    position: absolute;
    font-size:14px;
    color:blue;

}
#portals {
    position: absolute;
    margin-left: 110px;
    margin-top: 155px;
    display:none;
}
.tinyimg {
    width: 1px;
    height: 1px;
}

</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>

<script type="text/javascript">


$(document).ready(function(){
$('button').click(function(){
    $('#knocks').append('<p>Knocking...</p>');
    setTimeout(function(){
        $('#portals').append('<img class="tinyimg" src="https://some.url.com:1111/test/url.jpg/" />');
        $('#knocks').append("<p>Knock 1 of 5 complete...</p>");
        }, 500);    
    setTimeout(function(){
        $('#portals').append('<img class="tinyimg" src="https://some.url.com:2222/test/url.jpg/" />');
        $('#knocks').append("<p>Knock 2 of 5 complete...</p>");
        }, 3500);
    setTimeout(function(){
        $('#portals').append('<img class="tinyimg" src="https://some.url.com:3333/test/url.jpg" />');
        $('#knocks').append("<p>Knock 3 of 5 complete...</p>");
        }, 6500);
    setTimeout(function(){
        $('#portals').append('<img class="tinyimg" src="https://some.url.com:4444/test/url.jpg" />');
        $('#knocks').append("<p>Knock 4 of 5 complete...</p>");
        }, 9500)
    setTimeout(function(){
        $('#portals').append('<img class="tinyimg" src="https://some.url.com:5555/test/url.jpg/" />');
        $('#knocks').append("<p>Knock 5 of 5 complete...</p>");
        }, 12000);
    setTimeout(function(){
        $('#knocks').append("<p>Knocking is complete... <br>Proceed to site: <a href='http://secureurl.someurl.com'>http://secureurl.someurl.com/a></p>");
        }, 13000);
});
});


</script>

</head>
<body>
<div id="top">
<p><span id="heading">Gain Access</span><br><span id="subhead">Beta version 1.0</span></p>
</div>
<button type="button">Click to Knock</button>
<div id="portals"></div> <!--The image references created by the port knocks land in this div.-->
<p id="status">Status:</p>
<div id="knocks"><p>Click button to knock</p></div> <!--The status updates generated concurrently with each port knock are displayed here.-->
</body>
</html>

推荐答案

您正在使用GET请求图像来端口敲响服务器.我认为服务器不会回复这些请求,甚至不会过滤它们,因此它们最终将超时.

You are using GET requests for images to port knock on your server. I assume the server does not reply to these requests and even filters them, so they will eventually time out.

如果先前的尝试超时,则某些浏览器可能不愿意执行相同的请求.他们可能还会实现一个队列,并且仅同时发送几个请求,如果您在必须发送敲门声的下一部分(标准TCP超时为30秒)时这些请求仍然悬而未决,则会导致问题.

Some browsers might be reluctant to perform the same request if the previous attempts timed out. They may also implement a queue and only send a few requests at the same time, which can cause problems if these requests are still pending when you have to send the next part of your knock (standard TCP timeout being 30 seconds).

尽可能使用 WebSockets 重新实现敲门协议.

If at all possible, reimplement your knocking protocol with WebSockets.

如果您对图像不满意,请尝试在URL后面附加"?" + $.now(),以使它们对于每个请求而言都是唯一的.这可能有助于防止浏览器放弃特定的请求.

If you're stuck with images, try appending "?" + $.now()to your URLs so they become unique for each request. It might help preventing the browser from giving up on a specific request.

这篇关于基于jquery的独立端口敲门人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆