Community discussions

MikroTik App
Guscht
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Thu Jul 01, 2010 5:32 pm

NO WAY?! AI writes Mikrotik-Scripts...

Wed Dec 21, 2022 11:28 pm

Thats new to me... I said:
wirte a fancy mikrotik-script, so i can impress the guys in the mikrtoik-forum!

AI said:
Sure, here's a fancy script that demonstrates some advanced features of MikroTik RouterOS scripting:

It came up with this stuff:lol: :lol: :lol: :lol:(dont know if it works)

Code:Select all
# This script sets up a simple hotspot with user authentication # and bandwidth limiting, and sends a welcome message to the user # upon successful login. # First, define some variables for the hotspot and user settings :local hotspotName "My Fancy Hotspot" :local hotspotAddress "192.168.88.1" :local hotspotDns "8.8.8.8" :local hotspotNetmask "255.255.255.0" :local hotspotLeaseTime "1d" :local hotspotUamSecret "mysecret" :local hotspotUamServer "http://$hotspotAddress/hotspot" :local hotspotMaxUsers "20" :local userRateLimit "512k/512k" # Next, create the hotspot interface and set the required settings /interface wireless set [ find default-name=wlan1 ] ssid=$hotspotName set [ find default-name=wlan1 ] mode=ap-hotspot /ip pool add name=hotspot-pool ranges=$hotspotAddress/$hotspotNetmask /ip hotspot profile set [ find default=yes ] address-pool=hotspot-pool set [ find default=yes ] dns-server=$hotspotDns set [ find default=yes ] lease-time=$hotspotLeaseTime set [ find default=yes ] login-by=http-chap set [ find default=yes ] hotspot-address=$hotspotAddress set [ find default=yes ] hotspot-service=http set [ find default=yes ] hotspot-service=https set [ find default=yes ] hotspot-service=ssh set [ find default=yes ] hotspot-service=ftp set [ find default=yes ] hotspot-service=dns set [ find default=yes ] hotspot-service=smtp set [ find default=yes ] hotspot-service=pop3 set [ find default=yes ] hotspot-service=imap set [ find default=yes ] hotspot-service=radius set [ find default=yes ] hotspot-service=winbox set [ find default=yes ] hotspot-service=www set [ find default=yes ] hotspot-service=api /ip hotspot user profile set [ find default=yes ] rate-limit=$userRateLimit /ip hotspot add address=$hotspotAddress name=$hotspotName profile=default # Now, define the login and logout scripts that will be executed # when a user authenticates to the hotspot. # The login script sends a welcome message to the user and adds a # bandwidth limit to their connection. :local loginScript "" :local logoutScript "" :set loginScript [ /file get hotspot-login.rsc contents ] :set logoutScript [ /file get hotspot-logout.rsc contents ] /ip hotspot user profile set [ find default=yes ] on-login=$loginScript set [ find default=yes ] on-logout=$logoutScript # Finally, set the hotspot to start automatically on boot and # enable the hotspot service /system script add name=hotspot-start policy=ftp,reboot,



And a short AI-Mikrotik poem:
Mikrotik, oh Mikrotik,
A router that's truly quick,
Connecting all our devices,
With lightning-fast speeds.

Through rain or wind or snow,
You keep our connections flowing,
Your magic touch never fades,
In so many different ways.

Mikrotik, oh Mikrotik,
A hero of the internet,
We thank you for your service,
Our gratitude won't be inert.
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 1:08 am

AI?

Say: "write a mikrotik-script to convert IPv4 address to binary value"...

Say: "write a standard POSIX RegEx for identify IPv6"...


谁是白痴美联储错误数据或严重课题ammed the AI?
Just for example:
/interface wireless
set [ find default-name=wlan1 ] mode=ap-hotspot
Top
User avatar
anav
Forum Guru
Forum Guru
Posts: 17551
Joined: Sun Feb 18, 2018 11:28 pm
Location:Nova Scotia, Canada
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 4:32 am

I think you have "extended" someones lifespan, and the cat remains with 9 lives. May AI leave us alone a bit longer.
Top
Guscht
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Thu Jul 01, 2010 5:32 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 10:06 am

AI?
Say: "write a mikrotik-script to convert IPv4 address to binary value"...
Code:Select all
# Set the IPv4 address to be converted :local ipv4Address "192.168.0.1" # Split the IPv4 address into its octets :local octets [:toarray $ipv4Address] # Initialize the binary string :local binaryString "" # Iterate through each octet and convert it to binary :foreach octet in $octets do={ # Convert the octet to binary :local binaryOctet [:tobinary $octet] # Pad the binary octet with leading zeros until it has 8 digits :while ([:len $binaryOctet] < 8) do={ :set binaryOctet "0$binaryOctet" } # Append the binary octet to the binary string :set binaryString "$binaryString$binaryOctet" } # Print the binary string :put $binaryString
This script first sets the IPv4 address to be converted in the ipv4Address variable. It then splits the address into its octets using the :toarray function and stores them in the octets variable.

Next, the script initializes the binaryString variable as an empty string. It then iterates through each octet in the octets array and converts it to a binary value using the :tobinary function.

The binary value is then padded with leading zeros until it has 8 digits using a while loop and the :len function. Finally, the binary octet is appended to the binaryString variable.

After the loop completes, the script prints the final binary string using the :put command.

I hope this helps! Let me know if you have any questions.


AI?
Say: "write a standard POSIX RegEx for identify IPv6"...
Code:Select all
^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$
This regular expression will match any valid IPv6 address, including addresses with an embedded IPv4 address, and addresses with a link-local scope identifier.

Note that this regular expression may not work with all regex implementations, as it is written in POSIX extended regular expression syntax. Some implementations may require modification to support this syntax.
Top
Guscht
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Thu Jul 01, 2010 5:32 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 10:12 am

I think you have "extended" someones lifespan, and the cat remains with 9 lives. May AI leave us alone a bit longer.

For you, what the AI says:


To our dear anav,

We are pleased to present you with this MTUNA certificate in recognition of your dedication and contributions to the Mikrotik-Forum community.

MTUNA stands for Mikrotik Training and User Networking Association. It is a community of like-minded individuals who are passionate about learning and sharing knowledge about Mikrotik networking technology.

Through your participation and contributions in the forum, you have demonstrated a strong commitment to helping others and advancing the field of networking. You are a valuable member of the MTUNA community and we are grateful for all that you do.

Congratulations on receiving this MTUNA certificate and thank you for being an invaluable member of our community.

Sincerely,
The MTUNA Team
Top
Guscht
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Thu Jul 01, 2010 5:32 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 10:18 am

谁是白痴美联储错误数据或严重课题ammed the AI?
Just for example:
/interface wireless
set [ find default-name=wlan1 ] mode=ap-hotspot
I scolded AI:

It looks like the issue you are experiencing is that the "mode" property of the wireless interface is set to "ap-hotspot", but this value is not recognized by the router.

In Mikrotik routers, the mode of a wireless interface can be set to either "ap" (access point) or "station" (client). It appears that "ap-hotspot" is not a valid value for the mode property.

建立一个热点使用此脚本,您将不能ed to change the value of the "mode" property to "ap". For example:

/interface wireless
set [ find default-name=wlan1 ] ssid=$hotspotName
set [ find default-name=wlan1 ] mode=ap

This will set the wireless interface to operate as an access point, and will allow you to use the rest of the script to configure the hotspot.

I hope this helps! If you have any further questions or issues, don't hesitate to ask.
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 10:41 am

建立一个热点使用此脚本,您将不能ed to change the value of the "mode" property to "ap". For example:
set [ find default-name=wlan1 ] mode=ap
再次AI / AI程序员错误,“美联社”模式exist(*)...

(*) I do not have wifiwave2 devices for test, but is "ap-bridge" the right value
Top
p3rad0x
Long time Member
Long time Member
Posts: 632
Joined: Fri Sep 18, 2015 5:42 pm
Location:South Africa
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 10:42 am

The AI has "MTUNA", but is still unable to set the wireless mode correctly?
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 10:50 am

Code:Select all
# Set the IPv4 address to be converted :local ipv4Address "192.168.0.1" # Split the IPv4 address into its octets :local octets [:toarray $ipv4Address]
really things shot there at random ...
(it would be nice if toarray actually directly converts an IP to bytes... but that's another story)

Rex HI code

{ :local ipv4Address "192.168.0.1" :local octets [:toarray $ipv4Address] :put [:typeof $octets] :put "items on array $[:len $octets]" :put "octets is >$octets<" :put "$($octets->0) $[:typeof ($octets->0)]" :put "$($octets->1)" }
"octets" variable is the conversion of a string (ipv4Address) to one array, with one string inside...


this do not work also if ipv4Address is CORRECTLY set as IP instead of string...

Rex HI code

{ :local ipv4Address [:toip 192.168.0.1] :local octets [:toarray $ipv4Address] :put [:typeof $ipv4Address] :put [:typeof $octets] :put "items on array $[:len $octets]" :put "octets is >$octets<" :put "$($octets->0) $[:typeof ($octets->0)]" :put "$($octets->1)" }
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 10:57 am

:local binaryOctet [:tobinary$octet]
But… Does the AI have early access toOpenROS® 12.25?
:lol:
If AI invents anything, it should first of all do as people who really have intelligence do…
Check first il those instructions exist...


About previous post, give this link to the AI:
viewtopic.php?f=9&t=85205&p=431507#p880374
Probably can learn something....

Rex HI code

:global ip2array do={ :local ip [:toip $1] :local array [:toarray ""] :if ([:typeof $ip] != "ip") do={:return $array} :set ($array->0) $ip :set ($array->1) [:tonum (($ip >> 24) & 0.0.0.255)] :set ($array->2) [:tonum (($ip >> 16) & 0.0.0.255)] :set ($array->3) [:tonum (($ip >> 8 ) & 0.0.0.255)] :set ($array->4) [:tonum (($ip >> 0) & 0.0.0.255)] :return $array } # space on forum between 8 and ) because if not present, is translated to the emoticon8)...
I'm not saying it's the best possible script, but it's close to it, and above all... it works...
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 11:14 am

Code:Select all
^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$
I really hope it works, I've always been too lazy to study one actually working, given the complexity of the thing ...

But the RegEx fail (MikroTik or not)
For example, this valid IPv6 is not recognized...
::4321:5678:91.123.4.56
Top
holvoetn
Forum Guru
Forum Guru
Posts: 3984
Joined: Tue Apr 13, 2021 2:14 am
Location:Belgium

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 11:23 am

It might be better not to take this so seriously:lol:
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 11:27 am

P.S.:
I'm too lazy for IPv6 RegEx, but not for this: "write a mikrotik-script to convert IPv4 address to binary value"

Convert IPv4 to binary data:

Rex HI code

:global ip2bin do={ :local number [:tonum [:toip $1]] :local ret "" :for i from=0 to=31 step=1 do={ :set ret "$(($number >> $i) & 1)$ret" :if ([:tostr $i]~"^(7|15|23)\$") do={:set ret "$2$ret"} } :return $ret } # no separator :put [$ip2bin 192.168.0.1] # with separator for each 8 bit (can specified any, also "\r\n") :put [$ip2bin 192.168.0.1 "."]

:put [$ip2bin 192.168.0.1] = 11000000101010000000000000000001

:put [$ip2bin 192.168.0.1 "."] = 11000000.10101000.00000000.00000001

:put [$ip2bin 192.168.0.1 "\r\n"] =
11000000
10101000
00000000
00000001
Last edited byrextendedon Thu Dec 22, 2022 11:55 am, edited 1 time in total.
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 11:54 am

It might be better not to take this so seriously:lol:

however it programs better than many other improvised programmers here on the forum and on youtube & co. ...
:lol: :lol: :lol: :lol:
Top
User avatar
mkx
Forum Guru
Forum Guru
Posts: 10402
Joined: Thu Mar 03, 2016 10:23 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 12:14 pm

For you, what the AI says:


MTUNA stands for Mikrotik Training and User Networking Association. It is a community of like-minded individuals who are passionate about learning and sharing knowledge about Mikrotik networking technology.

Gosh, the self-proclaimed MTUNA team AI "thing" even got meaning of MTUNA wrong. As the founder of MTUNA certification programme, our beloved @anav could tell us that MTUNA stands for "MikroTikUncertifiedNetworkAmateur" ... has nothing much to do with what AI insinuates.

It shows how low are AI's skills of detecting sarcasm ... the fact that @anav is on the extreme side doesn't excuse AI a bit.
Top
Sob
Forum Guru
Forum Guru
Posts: 9185
Joined: Mon Apr 20, 2009 9:11 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 2:55 pm

Top
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 25916
Joined: Fri May 28, 2004 11:04 am
Location:Riga, Latvia

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 2:58 pm

You should correct it and tell ChatGPT what is right. It is capable of some learning:)
Top
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11586
Joined: Tue Feb 25, 2014 12:49 pm
Location:Italy
Contact:

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 3:12 pm

You should correct it and tell ChatGPT what is right. It is capable of some learning:)
Hi @normis,
any plans to releaseOpenROS® 12.25to the public?
(please be nice with the answer, Christmas is just around the corner) :lol:
Top
User avatar
mkx
Forum Guru
Forum Guru
Posts: 10402
Joined: Thu Mar 03, 2016 10:23 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 3:14 pm

any plans to releaseOpenROS® 12.25to the public?
(please be nice with the answer, Christmas is just around the corner) :lol:
... and ... AI is listening and learning:lol:
Top
User avatar
mkx
Forum Guru
Forum Guru
Posts: 10402
Joined: Thu Mar 03, 2016 10:23 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 3:17 pm


Uh, sorry ... I stand corrected ... the founder of MTUNA certificate programme, our beloved @Sob:-D

AI, did you get this?
Top
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 25916
Joined: Fri May 28, 2004 11:04 am
Location:Riga, Latvia

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 3:21 pm

I, for one, welcome our AI overlord
Top
User avatar
mkx
Forum Guru
Forum Guru
Posts: 10402
Joined: Thu Mar 03, 2016 10:23 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 5:06 pm

Uhmmm ... Normis, is this you? Or is this AI trying to mimick @Normis ... going overboard praising itself?:wink:
Top
Sob
Forum Guru
Forum Guru
Posts: 9185
Joined: Mon Apr 20, 2009 9:11 pm

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 7:04 pm

Some declarations just turn out to be premature.:)

troy.jpg
You do not have the required permissions to view the files attached to this post.
Top
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 2515
Joined: Sun May 01, 2016 7:12 pm
Location:California

Re: NO WAY?! AI writes Mikrotik-Scripts...

Thu Dec 22, 2022 9:04 pm

It would be interesting what some ML models could do with this forums' contents. Hard to know how many Mikrotik scripts be in a generic model used in OP's example. 600K+ posts for some AI to think about, with BB tags, view count, etc. etc., giving it some more clues.
Top

Who is online

Users browsing this forum:eworm,gigabyte091,Semrush [Bot]and 36 guests