Community discussions

MikroTik App
 
PaRaN0iD
newbie
Topic Author
Posts: 28
Joined: Sun Jan 08, 2012 7:46 pm

How to use keyboard shortcuts with scripts?

Mon Feb 06, 2012 3:23 pm

Hii guys

I want to insert a pppoe scan command in a script like this:
:global result;
:global resultLen;
:global startLoc;
:global endLoc;
:global Evilmac;
:global i;
:global mac mac;
:global End 0;
:global line "";
:global start 0;
:foreach i in=[/file find ] do={
:if ([/file get $i value-name=name ] = "console-dump.txt") do={
/file remove $i ;
}
}
/interface pppoe-client scan ether2 duration=00:00:10  <---This is the command
:put D                                                                   <---- the troubles arise here
:put Q
:delay 2s
:global content [/file get [/file find name=console-dump.txt] contents] ;
:global contentLen [ :len $content ] ;
:do {
         :set End [:find $content "\n" $start ] ;
         :set line [:pick $content $start $End] ;
         :set start ($End + 1) ;
         :if ( [:pick $line 0 1] != "#" && [:pick $line 0 1] != "S" ) do={
        :local entry [:pick $line 0 ($End -1) ]
        :global result ($entry);
        :global resultLen [:len $result];
        :global startLoc [:find $result "00:"];
        :global endLoc ($startLoc + 17);
        :global Evilmac [:pick $result $startLoc $endLoc];
        :put ($Evilmac);
        :log warning "Fake PPPOE Server Detected!";
/interface wireless access-list add mac-address=$Evilmac authentication=no forwarding=no;
/ip firewall filter add chain=forward src-mac-address=$Evilmac action=drop;
      } 
} while=($End < $contentLen)
every thing going ok till the (:put D) which dump the scan result to file it's not executed
I appreciate if any one can help me to pass this keyboard shortcut to script
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: How to use keyboard shortcuts with scripts?

Tue Feb 07, 2012 1:44 pm

results of scan cannot be saved to the variable.
 
PaRaN0iD
newbie
Topic Author
Posts: 28
Joined: Sun Jan 08, 2012 7:46 pm

Re: How to use keyboard shortcuts with scripts?

Tue Feb 07, 2012 5:36 pm

results of scan cannot be saved to the variable.
Thank you

I just want to dump scan result to file then get file contents
 
PaRaN0iD
newbie
Topic Author
Posts: 28
Joined: Sun Jan 08, 2012 7:46 pm

Re: How to use keyboard shortcuts with scripts?

Tue Feb 07, 2012 8:58 pm

Ok I get it!
:global result;
:global resultLen;
:global startLoc;
:global endLoc;
:global Evilmac;
:global i;
:global End 0;
:global line "";
:global start 0;
:foreach i in=[/file find ] do={
:if ([/file get $i value-name=name ] = "dump.txt") do={
/file remove $i ;
  }
}
/system logging add topics=pppoe action=memory;
/interface pppoe-client add name=dump interface=ether1 disabled=no;
:delay 5s;
/log print file=dump.txt where topics="pppoe,debug,packet"
:delay 3s;
:global content [/file get [/file find name=dump.txt] contents];
:global contentLen [ :len $content ] ;
:do {
        :set End [:find $content "\n" $start ] ;
        :set line [:pick $content $start $End] ;
        :set start ($End + 1) ;
        :if ([:len [:find $line "\_rcvd\_PADO\_from\_"]] > 0) do={
        :local entry [:pick $line 0 ($End -1) ]
        :global result ($entry);
        :global resultLen [:len $result];
        :global startLoc [:find $result "\_rcvd\_PADO\_from\_"] ;
		:set startLoc ($startLoc + [:len $startLoc] + 14);
        :global endLoc ($startLoc + 17);
        :global Evilmac [:pick $result $startLoc $endLoc];
		:if ([:len [/int w access-list find mac-address="$Evilmac"]] > 0) do={
		:log warning "Exists!"
		} else={
		/int w access-list add mac-address=$Evilmac authentication=no forwarding=no;
        /ip fire filter add chain=forward src-mac-address=$Evilmac action=drop;
        :log warning "Rouge PPPOE server BlockeD!";
        }
    }
} while=($End < $contentLen)
/inter pppoe-client remove dump
:global j;
:foreach j in=[/system logging find] do={
:if ([/system logging get $j value-name=topics] = "pppoe") do={
/system logging remove $j ;
  }
}
Image