• java扫描Web开放端口


    package com.safety;
    
    
    import cn.hutool.http.HttpUtil;
    
    import java.util.concurrent.CopyOnWriteArrayList;
    import java.util.concurrent.CountDownLatch;
    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    import java.util.concurrent.atomic.AtomicInteger;
    
    /**
     * Java实现多线程扫描开放端口
     * @author Administrator
     *
     */
    public class Demo extends Thread {
        public static void main(String[] args) throws InterruptedException {
            AtomicInteger count=new AtomicInteger(1);
            CopyOnWriteArrayList<Integer> objects = new CopyOnWriteArrayList<>();
            CountDownLatch countDownLatch = new CountDownLatch(65536);
            ExecutorService executorService = Executors.newFixedThreadPool(2500);
            for (int i = 1; i <= 65536; i++) {
                executorService.execute(new Runnable() {
                    @Override
                    public void run() {
                        try{
                            int i1 = count.addAndGet(1);
                            System.err.println("准备扫描:"+i1);
                            String body = HttpUtil.createGet("81.69.57.61:"+i1).execute().body();
                            System.err.println("====================================端口:"+i1);
                            objects.add(i1);
                            countDownLatch.countDown();
                        } catch (Exception e) {
                            countDownLatch.countDown();
                        }
                    }
                });
                Thread.sleep(1);
            }
            countDownLatch.await();
            System.err.println("扫描到以下端口:");
            objects.forEach(item->{
                System.err.print(item+"-");
            });
            System.err.println("=====================");
        }
    }

     需要hutool

  • 相关阅读:
    梦1
    ASP.Net Web Page深入探讨
    创建ASP.NET WEB自定义控件——例程3
    自定义有模板功能的控件
    .net中Web自定义控件编写注意事项
    一个javascript脚本网站
    今天
    Konami世界一代(1)
    使用随机数
    做了一个赋值的测试
  • 原文地址:https://www.cnblogs.com/xyzxy/p/14668661.html
Copyright © 2020-2023  润新知