Community discussions

MikroTik App
 
khaled11
just joined
Topic Author
Posts: 24
Joined: Mon Sep 30, 2013 7:09 pm
Location: lebanon

please Help me

Wed Apr 29, 2015 9:10 pm

i am using this script http://wiki.mikrotik.com/wiki/Using_Fet ... ress_Lists
the source file txt its from http://www.whatsapp.com/cidr.txt when i download the file cidr.txt from whatsapp.com
the ips appear like that [img]
Capture.JPG
[/img]
so the script
 ## Generic IP address list input
   ## Based on a script written by Sam Norris, ChangeIP.com 2008
   ## Edited by Andrew Cox, AccessPlus.com.au 2008
   :if ( [/file get [/file find name=ipaddress.txt] size] > 0 ) do={
   # Remove exisiting addresses from the current Address list
   /ip firewall address-list remove [/ip firewall address-list find list=MY-IP-LIST]
   
   :global content [/file get [/file find name=ipaddress.txt] contents] ;
   :global contentLen [ :len $content ] ;
   
   :global lineEnd 0;
   :global line "";
   :global lastEnd 0;
   
   :do {
         :set lineEnd [:find $content "\n" $lastEnd ] ;
         :set line [:pick $content $lastEnd $lineEnd] ;
         :set lastEnd ( $lineEnd + 1 ) ;
         #If the line doesn't start with a hash then process and add to the list
         :if ( [:pick $line 0 1] != "#" ) do={
   
        :local entry [:pick $line 0 ($lineEnd -1) ]
        :if ( [:len $entry ] > 0 ) do={
           /ip firewall address-list add list=MY-IP-LIST address=$entry
        }
      }
   } while ($lineEnd < $contentLen)
   }
not working
ANy idea to make a break btween the ips
PLZ HELP ME
You do not have the required permissions to view the files attached to this post.
 
vitorlins
just joined
Posts: 8
Joined: Tue Apr 14, 2015 7:48 pm

Re: please Help me

Thu Apr 30, 2015 2:28 am

Try:
31.13.65.49/32k31.13.66.49/32k31.13.69.240/32k31.13.70.49/32k31.13.71.49/32k31.13.73.49/32k31.13.74.49/32k31.13.76.81/32k31.13.77.49/32k50.22.75.192/27k50.22.93.192/27k50.22.198.204/30k50.22.210.32/30k50.22.210.128/27k50.22.225.64/27k50.22.235.248/30k50.22.240.160/27k50.23.90.128/27k50.97.57.128/27k75.126.39.32/27k108.168.174.0/27k108.168.176.192/26k108.168.177.0/27k108.168.180.96/27k108.168.254.65/32k108.168.255.224/32k108.168.255.227/32k158.85.0.96/27k158.85.5.192/27k158.85.46.128/27k158.85.48.224/27k158.85.58.0/25k158.85.61.192/27k158.85.224.160/27k158.85.233.32/27k158.85.249.128/27k158.85.249.224/27k158.85.254.64/27k169.53.29.128/27k169.53.250.128/26k169.54.2.160/27k169.54.210.0/27k169.54.222.128/27k173.192.162.32/27k173.192.219.128/27k173.192.222.160/27k173.192.231.32/27k173.193.205.0/27k173.193.230.96/27k173.193.230.128/27k173.193.230.192/27k173.193.239.0/27k174.36.208.128/27k174.36.210.32/27k174.36.251.192/27k174.37.199.192/27k174.37.215.28/30k174.37.217.64/27k174.37.231.64/27k174.37.243.64/27k174.37.251.0/27k184.173.73.176/28k184.173.136.64/27k184.173.147.32/27k184.173.161.64/32k184.173.161.160/27k184.173.173.116/32k184.173.179.32/27k184.173.195.32/27k184.173.201.32/27k184.173.204.32/27k184.173.250.53/32k192.155.212.192/27k198.11.193.182/31k198.11.212.0/27k198.11.217.192/27k198.11.251.32/27k198.23.80.0/27k198.23.86.224/27k198.23.87.64/27k208.43.115.192/27k208.43.117.79/32k208.43.117.136/32k208.43.122.128/27k2607:f0d0:1b01:d4::/64k2607:f0d0:3004:136::/64k2607:f0d0:3005:183::/64k2607:f0d0:3006:84::/64k2607:f0d0:3006:af::/64k2a03:2880:f000:d:face:b00c::167/128k2a03:2880:f001:d:face:b00c::167/128k2a03:2880:f003:c0d:face:b00c::167/128k2a03:2880:f00b:d:face:b00c::167/128k2a03:2880:f00d:d:face:b00c::167/128k2a03:2880:f011:d:face:b00c::167/128k2a03:2880:f012:d:face:b00c::167/128k2a03:2880:f013:d:face:b00c::167/128k2a03:2880:f022:d:face:b00c::167/128k
 ## Generic IP address list input
   ## Based on a script written by Sam Norris, ChangeIP.com 2008
   ## Edited by Andrew Cox, AccessPlus.com.au 2008
   :if ( [/file get [/file find name=ipaddress.txt] size] > 0 ) do={
   # Remove exisiting addresses from the current Address list
   /ip firewall address-list remove [/ip firewall address-list find list=MY-IP-LIST]
   
   :global content [/file get [/file find name=ipaddress.txt] contents] ;
   :global contentLen [ :len $content ] ;
   
   :global lineEnd 0;
   :global line "";
   :global lastEnd 0;
   
   :do {
         :set lineEnd [:find $content "k" $lastEnd ] ;
         :set line [:pick $content $lastEnd $lineEnd] ;
         :set lastEnd ( $lineEnd + 1 ) ;
         #If the line doesn't start with a hash then process and add to the list
         :if ( [:pick $line 0 1] != "#" ) do={
   
        :local entry [:pick $line 0 ($lineEnd -1) ]
        :if ( [:len $entry ] > 0 ) do={
           /ip firewall address-list add list=MY-IP-LIST address=$entry
        }
      }
   } while ($lineEnd < $contentLen)
   }
 
khaled11
just joined
Topic Author
Posts: 24
Joined: Mon Sep 30, 2013 7:09 pm
Location: lebanon

Re: please Help me

Thu Apr 30, 2015 2:30 pm

Try:
31.13.65.49/32k31.13.66.49/32k31.13.69.240/32k31.13.70.49/32k31.13.71.49/32k31.13.73.49/32k31.13.74.49/32k31.13.76.81/32k31.13.77.49/32k50.22.75.192/27k50.22.93.192/27k50.22.198.204/30k50.22.210.32/30k50.22.210.128/27k50.22.225.64/27k50.22.235.248/30k50.22.240.160/27k50.23.90.128/27k50.97.57.128/27k75.126.39.32/27k108.168.174.0/27k108.168.176.192/26k108.168.177.0/27k108.168.180.96/27k108.168.254.65/32k108.168.255.224/32k108.168.255.227/32k158.85.0.96/27k158.85.5.192/27k158.85.46.128/27k158.85.48.224/27k158.85.58.0/25k158.85.61.192/27k158.85.224.160/27k158.85.233.32/27k158.85.249.128/27k158.85.249.224/27k158.85.254.64/27k169.53.29.128/27k169.53.250.128/26k169.54.2.160/27k169.54.210.0/27k169.54.222.128/27k173.192.162.32/27k173.192.219.128/27k173.192.222.160/27k173.192.231.32/27k173.193.205.0/27k173.193.230.96/27k173.193.230.128/27k173.193.230.192/27k173.193.239.0/27k174.36.208.128/27k174.36.210.32/27k174.36.251.192/27k174.37.199.192/27k174.37.215.28/30k174.37.217.64/27k174.37.231.64/27k174.37.243.64/27k174.37.251.0/27k184.173.73.176/28k184.173.136.64/27k184.173.147.32/27k184.173.161.64/32k184.173.161.160/27k184.173.173.116/32k184.173.179.32/27k184.173.195.32/27k184.173.201.32/27k184.173.204.32/27k184.173.250.53/32k192.155.212.192/27k198.11.193.182/31k198.11.212.0/27k198.11.217.192/27k198.11.251.32/27k198.23.80.0/27k198.23.86.224/27k198.23.87.64/27k208.43.115.192/27k208.43.117.79/32k208.43.117.136/32k208.43.122.128/27k2607:f0d0:1b01:d4::/64k2607:f0d0:3004:136::/64k2607:f0d0:3005:183::/64k2607:f0d0:3006:84::/64k2607:f0d0:3006:af::/64k2a03:2880:f000:d:face:b00c::167/128k2a03:2880:f001:d:face:b00c::167/128k2a03:2880:f003:c0d:face:b00c::167/128k2a03:2880:f00b:d:face:b00c::167/128k2a03:2880:f00d:d:face:b00c::167/128k2a03:2880:f011:d:face:b00c::167/128k2a03:2880:f012:d:face:b00c::167/128k2a03:2880:f013:d:face:b00c::167/128k2a03:2880:f022:d:face:b00c::167/128k
 ## Generic IP address list input
   ## Based on a script written by Sam Norris, ChangeIP.com 2008
   ## Edited by Andrew Cox, AccessPlus.com.au 2008
   :if ( [/file get [/file find name=ipaddress.txt] size] > 0 ) do={
   # Remove exisiting addresses from the current Address list
   /ip firewall address-list remove [/ip firewall address-list find list=MY-IP-LIST]
   
   :global content [/file get [/file find name=ipaddress.txt] contents] ;
   :global contentLen [ :len $content ] ;
   
   :global lineEnd 0;
   :global line "";
   :global lastEnd 0;
   
   :do {
         :set lineEnd [:find $content "k" $lastEnd ] ;
         :set line [:pick $content $lastEnd $lineEnd] ;
         :set lastEnd ( $lineEnd + 1 ) ;
         #If the line doesn't start with a hash then process and add to the list
         :if ( [:pick $line 0 1] != "#" ) do={
   
        :local entry [:pick $line 0 ($lineEnd -1) ]
        :if ( [:len $entry ] > 0 ) do={
           /ip firewall address-list add list=MY-IP-LIST address=$entry
        }
      }
   } while ($lineEnd < $contentLen)
   }
but every day this list changed so its hard to insert letter K between the IP
 
psamsig
Member Candidate
Member Candidate
Posts: 161
Joined: Sun Dec 06, 2009 1:36 pm
Location: Denmark

Re: please Help me

Fri May 01, 2015 1:40 pm

There are breaks between the IPs, it is in UNIX format, so only terminated by a \n, not \r\n as Windows expect. Script almost worked, but would end in an endlless loop, if it didn't break on the IPv6 adresses (at least on mine, since I haven't IPv6 activated).

Here is one that work:
/file {
    :local fileId [find name=cidr.txt]
    :if ([:len $fileId] > 0 && [get $fileId size] > 0) do={
        :local content [get $fileId contents];

        /ip firewall address-list {
            remove [find list=MY-IP-LIST];

            :local contentLen [:len $content];
            :local lineEnd 0;
            :local lastEnd 0;

            :do {
                :set lineEnd [:find $content "\n" $lastEnd];
                :local entry [:pick $content $lastEnd $lineEnd];
                :set lastEnd ($lineEnd + 1);
                :if ([:len $entry] > 0 && [:find $entry ":"] < 0) do={
                    add list=MY-IP-LIST address=$entry;
                }
            } while ($lastEnd < $contentLen);
        }
    }
}
If needed it could problerly dowload cidr.txt as well.
 
IntrusDave
Forum Guru
Forum Guru
Posts: 1286
Joined: Fri May 09, 2014 4:36 am
Location: Rancho Cucamonga, CA

Re: please Help me

Fri May 01, 2015 6:36 pm

Is this for a blacklist of IP's to drop?
If so, I recommend a different method. I run a very simple script on my server every morning that pulls IP and CIDR blacklists from 3 different sources, Then the script reads the lists and writes them to a routeros script. Then an hour later, all of my MikroTik's download the script and run it.
 
khaled11
just joined
Topic Author
Posts: 24
Joined: Mon Sep 30, 2013 7:09 pm
Location: lebanon

Re: please Help me

Tue May 05, 2015 12:08 pm

There are breaks between the IPs, it is in UNIX format, so only terminated by a \n, not \r\n as Windows expect. Script almost worked, but would end in an endlless loop, if it didn't break on the IPv6 adresses (at least on mine, since I haven't IPv6 activated).

Here is one that work:
/file {
    :local fileId [find name=cidr.txt]
    :if ([:len $fileId] > 0 && [get $fileId size] > 0) do={
        :local content [get $fileId contents];

        /ip firewall address-list {
            remove [find list=MY-IP-LIST];

            :local contentLen [:len $content];
            :local lineEnd 0;
            :local lastEnd 0;

            :do {
                :set lineEnd [:find $content "\n" $lastEnd];
                :local entry [:pick $content $lastEnd $lineEnd];
                :set lastEnd ($lineEnd + 1);
                :if ([:len $entry] > 0 && [:find $entry ":"] < 0) do={
                    add list=MY-IP-LIST address=$entry;
                }
            } while ($lastEnd < $contentLen);
        }
    }
}
If needed it could problerly dowload cidr.txt as well.
Sorry nothing Work