Advertisement
fagci

Untitled

Oct 19th, 2021
3,440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 1.66 KB | None | 0 0
  1. #! /usr/bin/env elixir
  2.  
  3. defmodule NRFTP do
  4.   def check(ipa) do
  5.     {a, b, c, d} = ipa
  6.     ip = "#{a}.#{b}.#{c}.#{d}"
  7.  
  8.     try do
  9.       case :ftp.open(ipa, timeout: 700, dtimeout: 5000) do
  10.         {:ok, c} ->
  11.           case :ftp.user(c, ~c"guest", ~c"password") do
  12.             :ok ->
  13.               IO.puts(ip)
  14.               :ftp.close(c)
  15.  
  16.             _ ->
  17.               nil
  18.           end
  19.  
  20.         _ ->
  21.           nil
  22.       end
  23.     rescue
  24.       _ -> nil
  25.     catch
  26.       _ -> nil
  27.     end
  28.   end
  29. end
  30.  
  31. defmodule IPGen do
  32.   def gen_ip do
  33.     intip = Enum.random(0x1000000..0xE0000000)
  34.  
  35.     if (0xA000000 <= intip and intip <= 0xAFFFFFF) or
  36.          (0x64400000 <= intip and intip <= 0x647FFFFF) or
  37.          (0x7F000000 <= intip and intip <= 0x7FFFFFFF) or
  38.          (0xA9FE0000 <= intip and intip <= 0xA9FEFFFF) or
  39.          (0xAC100000 <= intip and intip <= 0xAC1FFFFF) or
  40.          (0xC0000000 <= intip and intip <= 0xC0000007) or
  41.          (0xC00000AA <= intip and intip <= 0xC00000AB) or
  42.          (0xC0000200 <= intip and intip <= 0xC00002FF) or
  43.          (0xC0A80000 <= intip and intip <= 0xC0A8FFFF) or
  44.          (0xC6120000 <= intip and intip <= 0xC613FFFF) or
  45.          (0xC6336400 <= intip and intip <= 0xC63364FF) or
  46.          (0xCB007100 <= intip and intip <= 0xCB0071FF) or
  47.          (0xF0000000 <= intip and intip <= 0xFFFFFFFF) do
  48.       gen_ip()
  49.     else
  50.       <<a, b, c, d>> = <<intip::unsigned-integer-size(32)>>
  51.       {a, b, c, d}
  52.     end
  53.   end
  54.  
  55.   def infinite do
  56.     Stream.repeatedly(&gen_ip/0)
  57.   end
  58. end
  59.  
  60. IPGen.infinite()
  61. |> Task.async_stream(&NRFTP.check/1, max_concurrency: 1024, ordered: false, timeout: :infinity)
  62. |> Stream.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement