To Creat a database for IP-Bot
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

To Creat a database for IP-Bot

Started by Chibok, 24 September, 2005, 19:06:23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chibok

I need who I can modify this script in order to verify in the RIPE Ranges contained in a Database and to write in another Database only the fields:

inetnum:
netname:
descr:
route:
example of the database of where to know you creak them to verify:
QuoteDataBase-1
TSDB._tmp = {
   ["_db"] = {
      [1] = "{62.41.70.32-62.41.70.95,\"Portugal\",\"PT\"}",
      [2] = "{62.48.128.0-62.48.255.255,\"Portugal\",\"PT\"}",
      [3] = "{62.93.191.248-62.93.191.255,\"Portugal\",\"PT\"}",
      [4] = "{62.169.64.0-62.169.127.255,\"Portugal\",\"PT\"}",
      [5] = "{62.185.133.96-62.185.133.127,\"Portugal\",\"PT\"}",
      [6] = "{62.186.192.0-62.186.192.79,\"Portugal\",\"PT\"}",
      [7] = "{62.186.192.88-62.186.192.255,\"Portugal\",\"PT\"}",
   },
   ["_type"] = "sort",
}
example of the database where to place the results of the asked for fields
QuoteTSDB._tmp = {
   ["_db"] = {
      [1] = "{62.41.70.32-62.41.70.95,\"Portugal\",\"PT\"inetnum\"netname\"descr\"route\"}",
      [2] = "{62.48.128.0-62.48.255.255,\"Portugal\",\"PT\"inetnum\"netname\"descr\"route\"}",
      [3] = "{62.93.191.248-62.93.191.255,\"Portugal\",\"PT\"inetnum\"netname\"descr\"route\"}",
      [4] = "{62.169.64.0-62.169.127.255,\"Portugal\",\"PT\"inetnum\"netname\"descr\"route\"}",
      [5] = "{62.185.133.96-62.185.133.127,\"Portugal\",\"PT\"inetnum\"netname\"descr\"route\"}",
   },
   ["_type"] = "sort",
}

I thank in advance your aid therefore this script is indispensable for the users of dc++ in Portugal

Chibok

I forgot myself to give the example of script to modify
Quote-- Ptokax LuaScript - written by bluebear.
-- This script is a part of the pxwsa.dll packages documentation.
-- Please read the license.txt before any usage, thx.
-- ==========================================================
-- File: AsyncWhois.lua
-- Usage: +whois
-- Arg: IP/DOMAIN/HOSTNAME
-- Desc:   Provides a +whois trigger to all users.
--      It only allows one user to use it at the time
--      Please note that this is a sample script.
--      I'm not a luascripter in any way.
--      You should finish this script, if you use it for
--      other things than testing.
--      You should add code for checking if the args
--      are valid so you wont crash ptokax.

-- options
rHost = "whois.ripe.net"
rPort = 43

-- Globals
running = nil
incomBuffer = ""
--Used for keeping track of user/socket/request (you should do this in tables to allow multiply users)
domain = nil
curUser = nil
curSocket = nil

-- Init lib
libinit = loadlib("pxwsa.dll", "_libinit")
libinit()

-- Init sockets
error_ = WSA.Init()

-- Resets the whois so a new users can use the trigger
function CloseSck()
   errorCode, errorStr = WSA.Close(curSocket)
   incomBuffer = ""
   domain = nil
   curUser = nil
   curSocket = nil
   running = nil
end

-- The next 3 functions is fired by the wsa lib when your useing async calls.

-- This function fires when a connection is established.
OnWsaConnected = function ( errorCode, errorStr, socket )
   if errorCode == nil then
      -- We're connected :)
      SendToNick(curUser, " SocketID: "..socket.." is now connected to: "..rHost..":"..rPort)
      -- Starte async receive
      WSA.BeginReceive(socket)
      -- Send request to whois server
      WSA.BeginSend(socket, domain)
   else
         -- Could not connect
      SendToNick(curUser, " Could not connect to: "..rHost..":"..rPort..". Error: "..errorCode.." "..errorStr)
      CloseSck()
   end   
   return 0
end

-- This function fires when a send is done. In this case it's when the whois request is sent.
OnWsaSendComplete = function ( errorCode, errorStr, socket, bytesSent )
   if errorCode == nil then
      SendToNick(curUser, " Sent on socket "..socket..": "..bytesSent.." bytes.")
   else
      -- Error dueing send
      SendToNick(curUser, " Could not send request to: "..rHost..":"..rPort..". Error: "..errorCode.." "..errorStr)
      CloseSck()   
   end
   return 0
end

-- This function fires when there is data available
OnWsaDataArrival = function ( errorCode, errorStr, socket, sdata, length )
   local retVal = 0 -- Return value
   if errorCode == nil then
             -- Receive done - but there can still be data on the socket you need to read.
      -- SendToNick(curUser, "Received "..length.." bytes from socket: "..socket.." Data: "..sdata)
      incomBuffer = incomBuffer..sdata
      -- return > zero to tell the lib that we still wants to receive data
      retVal = 1
   else
             -- Receive was an failure
             if errorCode == 0 then
                -- the connection has been gracefully closed by remotehost.
         SendToNick(curUser, " \n"..incomBuffer)
         SendToNick(curUser, " "..errorStr)
         CloseSck()
      else
         -- error
         SendToNick(curUser, " Error: "..errorCode.." "..errorStr)
         CloseSck()
             end
   end
   return retVal
end

-- Starts the lookup
function WhoisMain( curentUser, args)
   errorCode, errorStr, curSocket = WSA.NewSocket()
   -- Do error handles here
   curUser = curentUser
   domain = args.."\n"
   WSA.BeginConnect(curSocket, rHost, rPort)
end

-- parse
function Get1Arg(data)
   -- Written by plop
   local s,e,sArg = string.find(data, "%b<>%s+%pwhois%s+(%S+)")
   if sArg then
      return sArg
   end
end

-- Ptokax chat arrival
function ChatArrival(user, data)
   -- written by plop
   local data = string.sub(data, 1, (string.len(data) - 1))
   local sArg = Get1Arg(data)
   if sArg then
      if running == nil then
         -- arg found
         running = 1
         user:SendData(" looking "..sArg.." up at "..rHost)
         WhoisMain(user.sName, sArg)
      else
         user:SendData(" Sorry, I can only serve one user at the time. Please try agian in a few seconds..")
      end
      return 1
   else
      -- no arg found
   end
end

-- When ptokax stops
OnExit = function()
   -- clean up.
   local errorCode, errorStr = WSA.Dispose()
end

bastya_elvtars

If I understood correctly, you want to allow Portuguese users only which can be achieved using GeoIP.
Everything could have been anything else and it would have just as much meaning.

Chibok

yes is to using GeoIP, this I already obtain having only I creak them of Portugal in the Database. what I intend is still more advanced, he is to have a database with the some ISP, therefore in paid Portugal in way difrente in difrentes ISP, summarizing, who to belong to the ISP1 can be in hub but it cannot make DLL of the IPS2 if to be able to help I to me am thankful

bastya_elvtars

Well, you then will have to collect all IP-ranges of a specific ISP.
Everything could have been anything else and it would have just as much meaning.

Chibok

yes and for this I have to verify in the RIPE the data of the IPS and to write in the database the results as you must imagine you creak them are many and is imposivel to make this ? hand one to every month

Chibok

#6
in Portugal we have a serious problem with the behavior of the ISP's greaters what it originates great accounts in the end of the month, to try to reduce these accounts we have to have a IP-BOT layers to work the two levels: 1? Level to only allow entered of ips of Portugal 2? not to allow I pass through between some IPS (we already know which, now we lack to have a database with this information)


plus a tip this script is not for being to run in HUBs but to be used a time for month to bring up to date the database and this yes is for being used in HUBs in Portugal

pods to help me with script?
or you know of who can?

Chibok

when it is researched in RIPE this whole text is received
Quote% This is the RIPE Whois query server #2.
% The objects are in RPSL format.
%
% Note: the default output of the RIPE Whois server
% is changed. Your tools may need to be adjusted. See
% http://www.ripe.net/db/news/abuse-proposal-20050331.html
% for more details.
%
% Rights restricted by copyright.
% See http://www.ripe.net/db/copyright.html

% Note: This output has been filtered.
%       To receive output for a database update, use the "-B" flag

% Information related to '82.155.128.0 - 82.155.191.255'

inetnum:      82.155.128.0 - 82.155.191.255
netname:      TELEPAC-DSL
descr:        Telepac - Comunicacoes Interactivas, SA
descr:        DSL Service Networks
country:      PT
remarks:      NCC#2004125788
admin-c:      PG259-RIPE
tech-c:       AA2895-RIPE
status:       ASSIGNED PA
mnt-by:       TELEPAC-MNT
mnt-lower:    TELEPAC-MNT
mnt-routes:   TELEPAC-MNT
source:       RIPE # Filtered

person:       Pedro Jose Goncalves
address:      Telepac II - Comunicacoes Interactivas, SA
address:      Av. Fontes Pereira de Melo, 40
address:      Forum Picoas - 1069-300 Lisboa
address:      PT
phone:        +351-21-7907000
fax-no:       +351-21-7907001
nic-hdl:      PG259-RIPE
remarks:      *** PLEASE READ THIS ***
remarks:      I am NOT hacking into your computer!
remarks:      I am listed here as contact for certain network IP blocks
remarks:      allocated and assigned to Telepac II, SA ISP services.
remarks:      Please DO NOT send me any reports of network abuse.
remarks:      For abuse reports e-mail to abuse@mail.telepac.pt
remarks:      *** THANK YOU ***
e-mail:       pgoncalves@mail.telepac.pt
mnt-by:       TELEPAC-MNT
source:       RIPE # Filtered

person:       Alfredo Alvim
address:      Telepac II - Comunicacoes Interactivas, SA
address:      Av. Fontes Pereira de Melo, 40
address:      Forum Picoas - 1069-300 Lisboa
address:      PT
phone:        +351-21-7900000
fax-no:       +351-21-7907001
e-mail:       aalvim@tp.telepac.pt
nic-hdl:      AA2895-RIPE
remarks:      For abuse related reports, please use abuse@mail.telepac.pt
mnt-by:       TELEPAC-MNT
source:       RIPE # Filtered

% Information related to '82.154.0.0/15AS3243'

route:        82.154.0.0/15
descr:        Telepac II - Comunicacoes Interactivas, SA
origin:       AS3243
mnt-by:       TELEPAC-MNT
source:       RIPE # Filtered
of which just she intend to keep this
Quoteinetnum:      82.155.128.0 - 82.155.191.255
netname:      TELEPAC-DSL
descr:        Telepac - Comunicacoes Interactivas, SA
descr:        DSL Service Networks
country:      PT

as the research is configured for just to show the intended fields?

   local _,_,sName = string.find(sData, "(%S+)%s+%S+|route:")
who can help myself to configure the sting.find to keep just what is intended

Chibok

thank you Mutor, will be seen now if I already get the result that I intend

Chibok

#9
I put
Quote------------------------------------------------------------------------------------------------ identificar a Range
         local _,name,ip1,ip2 = string.find(incomBuffer,"inetnum%:%s+(%d+%.%d+%.%d+%.%d+)%s+%-%s+(%d+%.%d+%.%d+%.%d+)")
         ------------------------------------------------------------------------------------------------ identificar o nome do ISP
         local _,_,isp = string.find(incomBuffer,"netname%:%s+(%S+)")
         ------------------------------------------------------------------------------------------------ identificar o nome do PAIS
         local _,_,pais = string.find(incomBuffer,"country%:%s+(%S+)")
         SendToNick(curUser, " \n->"..ip1.."-"..ip2.."<->"..pais.."<->"..isp.."<-")
and I received
Quote->82.155.128.0-82.155.191.255<->PT<->TELEPAC-DSL<-
great help!  problem solved passed already for the next stage

SMF spam blocked by CleanTalk