Giter Club home page Giter Club logo

html_tools's People

Contributors

xinyu2428 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

html_tools's Issues

瞎整

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>数据 Conversion</title>
</head>
<style type="text/css">
    /* https://c.runoob.com/codedemo/3117/ */
    
    * {
        margin:0;
        padding:0;
    }
    
    html, body {
        width: 100%;
        height: 100%;
        background-color: grey;
        
    }
    
    div.btn-group {
        display: inline-block;
        width: 15%;
        height: 300px;
        vertical-align: top;
        
        float: left;
        margin: 0px 10px 0px 0px;
        
        /* position: relative; */

    }

    .btn-group button {
        background-color: #4CAF50;
        /* Green background */
        border: 1px solid green;
        /* Green border */
        color: white;
        /* White text */
        padding: 10px 24px;
        /* Some padding */
        cursor: pointer;
        /* Pointer/hand icon */
        width: 100%;
        /* Set a width if needed */
        display: block;
        /* Make the buttons appear below each other */
    }

    .btn-group button:not(:last-child) {
        border-bottom: none;
        /* Prevent double borders */
    }

    /* Add a background color on hover */
    .btn-group button:hover {
        background-color: #3e8e41;
    }
    
    .text-group {
        display: inline;
    }

    .text-group textarea {
        height: 98%;
        border: 1px solid rgb(128, 0, 107);
        background-color: rgb(68, 68, 68);
        color: rgb(16, 224, 86);
        font-family: Arial, Helvetica, sans-serif;
        font-size: 15px;
        
        /* margin-left:0px;
        padding-left: 10px; */
    }

    /* textarea:focus {
        border: 1px solid rgb(221, 56, 84);
    } */
</style>

<body>
    <div class="btn-group">
        <button id="quchong" onclick="dataCleaning()" title="示例: 放入文本,IP,子域名...">去重排序求差集</button>
        <button id="quchong" onclick="mergeSubdomainAndPort()">组合域名与端口</button>
        <button id="quchong" onclick="getNmapResult()" title="Nmap扫描记录信息提取,将IP与端口合并成URL">Nmap端口提取</button>
        <button onclick="getIP()" title="提取文本中所有的IP">IP提取</button>
        <button onclick="getURL()">子域名提取</button>
        <button onclick="getIP2()" title="示例(支持B段C段): 192.168.7.*;192.168.*.1;192.168.*.*">IP生成</button>
        <button onclick="clean()" title="清空内容">Clean</button>
        <button onclick="hide()" title="隐藏"><<<</button>
    </div>
    
    <div class="text-group">
        <textarea id="new"     style="width: 30%;" placeholder="基础数据内容" ></textarea>
        <textarea id="history" style="width: 23%;" placeholder="输入数据过滤" ></textarea>
        <textarea id="result"  style="width: 30%;" placeholder="数据处理结果" ></textarea>
    </div>
</body>

<script type="text/javascript">
    var dom_textarea_history = document.getElementById("history") //历史记录资产
    var dom_textarea_new     = document.getElementById("new")     //新资产
    var dom_textarea_result  = document.getElementById("result")  //结果输出


    function getIP2() {
        var list_result = []
        var list_new_text = unique(dom_textarea_new.value.split("\n"));
        var reg = /\*/g
        // if(list_new_text.length==1){
        //     var str = list_new_text[0]
        //     for(var i=0; i<256; i++){
        //         list_result.push(str.replace("*", i))
        //     }
        // }

        for (const key in list_new_text) {
            var str = list_new_text[key]
            if (str.match(reg) != null) {
                var num = str.match(reg).length
                if (num == 1) {
                    for (var i = 0; i < 256; i++) {
                        list_result.push(str.replace("*", i))
                    }
                    str = str.replace("*", 0)
                    console.log("第" + key + "行: (" + list_new_text[key] + ")识别成功")
                } else if (num == 2) {
                    for (var i = 0; i < 256; i++) {
                        var str2 = str.replace("*", i)
                        for (var j = 0; j < 256; j++) {
                            list_result.push(str2.replace("*", j))
                        }
                    }
                    console.log("第" + key + "行: (" + list_new_text[key] + ")识别成功")
                } else {
                    alert("不支持A段生成")
                }

            } else {
                console.log("第" + key + "行: (" + list_new_text[key] + ")未识别到 * 号标记")
            }
        }
        dom_textarea_result.value = "---<" + list_result.length + ">---\n" + list_result.join("\n")
    }


    /*合并子域与端口信息, 暂时用处不大*/
    function mergeSubdomainAndPort() {
        var list_result = []
        var list_history_text = unique(dom_textarea_history.value.split("\n"));
        var list_new_text = unique(dom_textarea_new.value.split("\n")); //以换行符为分隔符获取文本数组并去重
        dom_textarea_history.value = list_history_text.join("\n")
        dom_textarea_new.value = list_new_text.join("\n")

        for (const i in list_history_text) {
            var str_list = list_history_text[i].split(":")
            console.log(str_list)
            for (const j in list_new_text) {
                var str2_list = list_new_text[j].split(":")
                if (str_list[1] == str2_list[0]) {
                    list_result.push("http://" + str_list[0] + ":" + str2_list[1])
                    list_result.push("https://" + str_list[0] + ":" + str2_list[1])
                    console.log("http://" + str_list[0] + ":" + str2_list[1])
                }
            }
        }
        list_result = unique(list_result)
        dom_textarea_result.value = "---组合地址数量<" + list_result.length + ">---\n" + list_result.join("\n")
        console.log("测试456")
    }

    function getURL() {
        // alert("感觉实际用途不大,先放着")
        var list_result = []
        var reg = /([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}/g
        //var ref = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/
        var list_new_text = dom_textarea_new.value.split("\n"); //以换行符为分隔符获取文本数组
        for (var i = 0; i < list_new_text.length; i++) {
            console.log(list_new_text[i])
            // console.log(reg.test(ip)) //匹配成功返回true
            var list_text = list_new_text[i].match(reg)
            if (list_text != null) {
                console.log(list_text)
                list_result.push.apply(list_result, list_text)
            } else {
                console.log("第" + (i + 1) + "行未提取到IP")
            }
        }
        list_result = unique(list_result) //去空行(忽略)-->去重-->排序
        dom_textarea_result.value = "---提取URL数量<" + list_result.length + ">---\n" + list_result.join("\n")
    }

    /*
    将提供的IP地址转换为对应的C段输出
    */
    function getIP() {
        var list_result = []


        var reg = /(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[0-9])\.((1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.){2}(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)/g
        var list_new_text = dom_textarea_new.value.split("\n"); //以换行符为分隔符获取文本数组
        for (var i = 0; i < list_new_text.length; i++) {
            console.log(list_new_text[i])
            // console.log(reg.test(ip)) //匹配成功返回true
            var list_text = list_new_text[i].match(reg)
            if (list_text != null) {
                console.log(list_text)
                list_result.push.apply(list_result, list_text)
            } else {
                console.log("第" + (i + 1) + "行未提取到IP")
            }
        }
        list_result = unique(list_result) //去空行(忽略)-->去重-->排序
        dom_textarea_result.value = "---提取IP数量<" + list_result.length + ">---\n" + list_result.join("\n")


        var cduan_result_list = []
        for (var i = 0; i < list_result.length; i++) {
            var temp = list_result[i].substr(0, list_result[i].lastIndexOf(".")) + ".0/24"
            cduan_result_list.push(temp)
        }

        var dic = {}
        for (const key in cduan_result_list) {
            console.log(cduan_result_list[key])
            if (dic.hasOwnProperty(cduan_result_list[key])) {
                dic[cduan_result_list[key]] += 1
            } else {
                dic[cduan_result_list[key]] = 1
            }
        }
        var dic2 = Object.keys(dic).sort(function (a, b) { return dic[b] - dic[a]; });
        dom_textarea_result.value += "\n\n\n---提取C段数量<" + dic2.length + ">---\n"
        for (const key in dic2) {
            console.log("key: " + dic2[key] + " ,value: " + dic[dic2[key]]);
            dom_textarea_result.value += dic2[key] + "(" + dic[dic2[key]] + ")\n"
        }
    }



    /*
    Nmap扫描记录处理
    */
    function getNmapResult() {
        var list_result = []
        var list_new_text = dom_textarea_new.value.split("\n"); //以换行符为分隔符获取文本数组
        //var reg_ip = /\(((1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[0-9])\.((1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.){2}(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d))\)/
        var reg_ip = /((1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|[0-9])\.((1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d)\.){2}(1\d{2}|2[0-4]\d|25[0-5]|[1-9]\d|\d))/
        var reg_port = /(\d*)\/tcp/
        for (const i in list_new_text) {
            var ip, port
            let temp = list_new_text[i]
            var list_text = temp.match(reg_ip)
            if (list_text != null) {
                ip = list_text[1]
                // console.log(ip)
            } else {
                if (reg_port.test(temp)) {
                    var list_text = temp.match(reg_port)
                    port = list_text[1]
                    console.log(ip + ":" + port)
                    //未找到IP直接匹配到端口的情况忽略
                    if (ip) {
                        list_result.push("http://" + ip + ":" + port)
                    }

                }
            }
        }
        list_result = unique(list_result)
        dom_textarea_result.value = "---合成地址数量<" + list_result.length + ">---\n" + list_result.join("\n")
    }


    function dataCleaning() {
        // var dom_textarea_history = document.getElementById("history") //历史记录资产
        // var dom_textarea_new = document.getElementById("new") //新资产
        // var dom_textarea_result = document.getElementById("result") //结果输出

        var list_history_text = unique(dom_textarea_history.value.split("\n"));
        var list_new_text = unique(dom_textarea_new.value.split("\n")); //以换行符为分隔符获取文本数组并去重
        //js 获取两个数组的交集,并集,补集,差集
        //https://www.cnblogs.com/web-shu/p/13551942.html

        //差集:数组arr1相对于arr2所没有的
        let diff = list_new_text.filter(function (val) { return list_history_text.indexOf(val) === -1 })
        //交集
        let intersection = list_history_text.filter(function (val) { return list_new_text.indexOf(val) > -1 })

        dom_textarea_history.value = list_history_text.join("\n")
        dom_textarea_new.value = list_new_text.join("\n")
        dom_textarea_result.value = "---差集<" + diff.length + ">---\n" + diff.join("\n")
        dom_textarea_result.value += "\n\n\n---交集<" + intersection.length + ">---\n" + intersection.join("\n")
        console.log("测试123")
    }


    //通用
    //功能: 去空行-->去重-->排序
    function unique(arr) {
        var result = [],
            hash = {};
        for (var i = 0, elem; (elem = arr[i]) != null; i++) {
            elem = elem.trim(); //去除收尾空字符
            //判断当前元素是否为空行
            if (elem != "") {
                if (!hash[elem]) {
                    result.push(elem);
                    hash[elem] = true;
                }
                // console.log(elem)
            }

        }
        // return result;
        return result.sort(function (a, b) { return a.localeCompare(b) }); //排序后在输出
    }
    
    function clean(){
        dom_textarea_history.value = "";
        dom_textarea_new.value = "";  
        dom_textarea_result.value = "";    
    }


</script>

</html>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.