Jump to content

Mikrotik Web Proxy White & Black List Import


bhns
 Share

Recommended Posts

Hello,

Mikrotik Web Proxy White & Black List Import

Tanks forum autoit... contribuited my script BlaclistImportMK

#include<GuiComboBox.au3>
#include<GUIConstantsEx.au3>
#include<Constants.au3>
#include<File.au3>
#include<Array.au3>
#include<ButtonConstants.au3>
#include<ComboConstants.au3>
#include<EditConstants.au3>
#include<StaticConstants.au3>
#include<WindowsConstants.au3>

local $black_file, $coments, $rediretions, $export_list_type
$data = ("" & @MDAY & "/" & @MON & "/" & @YEAR)
$horario = ("" & @HOUR & ":" & @MIN & ":" & @SEC)
$nomeComputador = @ComputerName
$usuarioLogado = @UserName
Local $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"

#Region ### START Koda GUI section ### Form=c:\dados\mikrotik _projects\import_to_export.kxf
$Form1 = GUICreate("Export to Mikrotik by BHNS", 361, 396, 410, 220)
$blacklist = GUICtrlCreateGroup("IMPORT BLACKLIST", 46, 40, 265, 81)
$Button1 = GUICtrlCreateButton("Import", 128, 70, 107, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$mikrotik = GUICtrlCreateGroup("EXPORT TO MIKROTIK", 46, 136, 265, 177)
$coment_ = GUICtrlCreateInput("--------------COMMENT-------------", 162, 168, 121, 21)
$action_lab = GUICtrlCreateLabel("Action :", 120, 201, 40, 17)
$list_name = GUICtrlCreateLabel("Coment Name List :", 63, 170, 96, 17)
$redire_label = GUICtrlCreateLabel("Redirection to :", 84, 234, 76, 17)
$redrection_out = GUICtrlCreateInput("google.com.br", 162, 232, 121, 21)
$Combo1 = GUICtrlCreateCombo("Select", 162, 199, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Allow|Deny|Deny + Redirecti|", "Deny + Redirecti")
$Label3 = GUICtrlCreateLabel("SubDomains :", 88, 269, 70, 17)
$Radio1 = GUICtrlCreateRadio("Yes", 173, 269, 57, 17)
$Radio2 = GUICtrlCreateRadio("No", 232, 269, 57, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$bt_gerar = GUICtrlCreateButton("Export", 93, 325, 75, 25)
$bt_exit = GUICtrlCreateButton("Exit", 189, 325, 75, 25)
$Label1 = GUICtrlCreateLabel("clebe@live.com", 272, 376, 80, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $bt_exit
Exit
Case $Button1
Local $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
Local $message = "Hold down Ctrl or Shift to choose multiple files."

Local $var = FileOpenDialog($message,$MyDocsFolder & "\", "Files (*.txt;*.*)", 1 + 4)

If @error Then
MsgBox(4096, "Erro", "No File(s) chosen")
Else
$var = StringReplace($var, "|", @CRLF)
MsgBox(4096, "", "You chose " & $var)
EndIf


Case $bt_gerar

$export_list_type = GUICtrlRead($Combo1)
$coments = GUICtrlRead($coment_)
$rediretions = GUICtrlRead($redrection_out)
; "Allow|Deny|Deny + Redirecti|", "Deny + Redirecti")

Select
Case GUICtrlRead($Radio1) = $GUI_CHECKED
$opt_select = "*"
Case GUICtrlRead($Radio2) = $GUI_CHECKED
$opt_select = ""
EndSelect


export_mikrotik ()



EndSwitch
WEnd


Func export_mikrotik ()



$black_file = $var


; Multiple filter group
$salv_file = FileSaveDialog("Export.", $MyDocsFolder, " Text files (*.ini;*.txt)", 2)
; option 2 = dialog remains until valid path/file selected

If @error Then
MsgBox(4096, "", "Exiting.")
exit
EndIf


; Check if file opened for writing OK
If $black_file = -1 Then
MsgBox(0, "Error", "Não foi possivel abrir o arquivo.")
Exit
EndIf

ProgressOn ( "Criando Export", "Adicioando Conteudo" , "" , -1 , -1 , 18)
;
; Sample export Mikrotik
; add action=allow disabled=yes dst-host=*gmail* dst-port=""

$ganb = '"'

FileWriteLine($salv_file, "# "&$data&" "&$horario&" by "&$usuarioLogado&" "&$nomeComputador&" RouterOS 5.X.X" & @CRLF)
FileWriteLine($salv_file, '# Arquivo carregado '& $ganb& $black_file& $ganb&''& @CRLF)
FileWriteLine($salv_file, "# " & @CRLF)
FileWriteLine($salv_file, "#" & @CRLF)
FileWriteLine($salv_file, "#" & @CRLF)
FileWriteLine($salv_file, "#" & @CRLF)
FileWriteLine($salv_file, "/ip proxy access" & @CRLF)
FileWriteLine($salv_file, 'add action=allow comment='&$ganb&$coments&$ganb&' disabled=no dst-host=1 dst-port="" '& @CRLF)
;FileWriteLine($salv_file, "add action=allow disabled=yes dst-host=*"&$linein&" dst-port=""" & @CRLF)
$inifile = FileOpen($black_file, 0)
$totallines = 0
While 1
FileReadLine($inifile)
If @error = -1 Then ExitLoop
$totallines += 1
WEnd
$sectionstartline = 1 ; First line of the section in the ini
$startvalue = 1 ;Start number for GUI
$totallines = ($totallines - $sectionstartline) + $startvalue
While 1
$linein = FileReadLine($inifile, $sectionstartline)
If @error = -1 Then ExitLoop

if $export_list_type = 'Allow' then
; add action=allow disabled=yes dst-host=*gmail* dst-port=""
FileWriteLine($salv_file, 'add action=allow disabled=no dst-host='&$opt_select&$linein&' dst-port=""'& @CRLF)

elseif $export_list_type = 'Deny' then
; add action=allow disabled=yes dst-host=*gmail* dst-port=""
FileWriteLine($salv_file, 'add action=deny disabled=no dst-host='&$opt_select&$linein&' dst-port=""' & @CRLF)

elseif $export_list_type = 'Deny + Redirecti' then
; add action=allow disabled=yes dst-host=*gmail* dst-port=""
FileWriteLine($salv_file, 'add action=deny disabled=no dst-host='&$opt_select&$linein&' dst-port="" redirect-to='&$rediretions&' '& @CRLF)

Endif
; add action=allow disabled=yes dst-host=*gmail* dst-port=""
; FileWriteLine($salv_file, "add action=allow disabled=yes dst-host=*"&$linein&" dst-port=""" & @CRLF)

;ConsoleWrite($startvalue & '/' & $totallines & @CRLF)
;If StringInStr($linein, '=') Then
; $infosplit = StringSplit($linein, '=')
; _AddRecord($DB, $DBTABLE, $DBOBJ, StringUpper($infosplit[1]) & '|' & $infosplit[2])
;EndIf
$UpdatePercentDone = ($startvalue / $totallines) * 100
ProgressSet($UpdatePercentDone, $linein, "Adding domains: " & $startvalue & '/' & $totallines)
$sectionstartline += 1
$startvalue += 1
WEnd
FileWriteLine($salv_file, "# Arquivo Gerado com Sucesso... by BHNS" & @CRLF)
FileClose($startvalue)

ProgressOff()

MsgBox(0, "OK", "Script Gerado com Sucesso")


EndFunc
Edited by bhns

:bike: 

Att...Cleber Antônio Made in Bio zonte Minas Gerais  :sweating:

Link to comment
Share on other sites

input Read file, >>

007jokes.com

01buzz.fr

01humours.com

09h09.com

output file >

/ip proxy access

add action=allow comment="--------------HUMOR-------------" disabled=no dst-host=1 dst-port=""

add action=deny disabled=no dst-host=*007jokes.com dst-port="" redirect-to=xxx.com.br

add action=deny disabled=no dst-host=*01buzz.fr dst-port="" redirect-to=xxx.com.br

add action=deny disabled=no dst-host=*01humours.com dst-port="" redirect-to=xxxx.com.br

add action=deny disabled=no dst-host=*09h09.com dst-port="" redirect-to=xxx.com.br

Option, lock or unlock & redirection web sites..... CTRL + C..... CTRL + V terminal mikrotik.

Para criar grandes lista automatica de regras no web proxy do mikrotik, server para bloquear ou criar uma liberação com opção de redirecionar a acão.

:bike: 

Att...Cleber Antônio Made in Bio zonte Minas Gerais  :sweating:

Link to comment
Share on other sites

Yes you define

you download free + 2.000.000 de web sites for list.

porn, games, chat, white list...

http://www.squidguard.org/blacklists.html

:bike: 

Att...Cleber Antônio Made in Bio zonte Minas Gerais  :sweating:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...