Script to identify conficker (virus infected) users

Hello all,

Just finished posting a wiki article on a script I’ve done up to help identify private network (lan) users infected with variants of the conficker virus.

Implementation of the script will give you a way to get the IP addresses of users on your network attempting to access sites that conficker ‘phones home’ to periodically.

If anyone has any questions, bugs or suggestions on the script feel free to voice them here.

Wiki article: http://wiki.mikrotik.com/wiki/Conficker-Virus-Blocking

oh bugger. Just found out that the :resolve command failing causes a script to halt in 3.X
Workaround for me was to use OpenDNS as the name servers, so that all requests would resolve, then just catch the users heading to non opendns IP’s.

http://forum.mikrotik.com/t/script-file-and-resolve-return-values-file-solved/26182/1 - could you please try to fix this for us mikrotik? The bug has been around since Feb.

Thanks.

Thanks!

Hi there

i use this script in x3.17 its not working for me i just modified the script to check they resolve the ips . i created the file name conf.txt and put the all domain which listed on site. i used opendns for nameserver

:local content [/file get [/file find name=“conf.txt”] contents] ;
:local contentLen [ :len $content ] ;

:local lineEnd 0;
:local line “”;
:local lastEnd 0;

:do {
:set lineEnd [:find $content “\n” $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;

#resolve each new line and add to the address list daily-conficker
:if ( [:pick $line 0 1] != “\n” ) do={
:local entry [:pick $line 0 ($lineEnd ) ]
:if ( [:len $entry ] > 0 ) do={
:local listip [:resolve “$entry”]
:if ($listip != “failure” ) do={
/ip firewall address-list add list=daily-conficker address=$listip
:log info “$listip”
}
}
}
} while ($lineEnd < $contentLen)
}
:log info “Address List Modification Complete”

Yes, as noted in my post above, I only found out after finishing the scrip that the mikrotik :resolve command is currently broken, any failed resolution simple forces the script to quit, hence using opendns is the only way I see to get it to complete at this time.. too bad we’ve got no other solution for the 1st April :frowning:

However, if you’re still getting an error in the script even thou all addresses are resolving, run it from terminal instead and let me know what line it errors on and I’ll have a look.

Thanks.

I managed to get it working and it’s popping up hits on several of my access points.
I copied the address list and firewall rule to the access points to isolate the customer.
I checked some of the ip address against arin.
208.69.36.132 opendns
72.167.202.5 godaddy
72.14.205.102 google

Does that seem right??

Also, could one just block the ip addresses from the list daily-conficker?

Yes you can block the addresses, I’ve done so on my sites and haven’t had any users call with issues accessing google :-/ (Roughly 3000 users its running across at the moment)

as for the ARIN listings, try the following addition. Change the line

/ip firewall address-list add list=daily-conficker address=$listip

to

/ip firewall address-list add list=daily-conficker address=$listip comment=$entry

This should give you a listing of the domain that each address was resolved from so you can see exactly which domain is which.
I’ve updated the script to include this.

Dude
Can you post the resolve export ips list so i can direcly add in addresses list

got error when i post the script on terminal window
conf.JPG

the whole reason the script goes through and resolves each of the IP’s is because conficker uses a new set of domains each day, if I were to resolve all of them now and just provide an IP list, this list could easily change within a few days time given that a) new domains that weren’t resolving previously may have now been purchased. b) old domains that were pointing elsewhere before could have records updated to point to new sites.

When I say run it from terminal I mean goto terminal and type in

/system run script daily-conficker-list

then paste the output.

Pasting in terminal like that simply won’t work.

Thanks for your prompt response. actully i have over 2500 user. most of the user are infacted with this virus.

here is terminal output

[admin@MikroTik] > /system run script daily-conficker-list
bad command name run (line 1 column 9)
[admin@MikroTik] >
conf.JPG

arggh sorry, typo

/system script run daily-conficker-list

is what you want to do.

something wrong in script when i run given error. see my last post


the worm has been activated on my lan users here is my squid access log.

1238397620.731 0 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
53 -1238397620.747 1037 192.168.0.5 TCP_MISS/200 345 GET http://210.2.138.215/tradingterminal/ExchangeWatch/ExchangeViewServer.aspx?Index=KSE100&q=0.3377882676355183 - DIRECT/210.2.138.215 text/xml
1238397620.760 296 192.168.0.5 TCP_MISS/204 187 GET http://www.google.com/uds/stats?r0=hl|search - DIRECT/216.239.61.104 text/html
1238397620.762 1 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.789 338 192.168.0.5 TCP_MISS/204 277 GET http://www.google.com.pk/csi?v=3&s=webhp&action=&tran=undefined&ei=83TQSdrkLdWSkAWSqsTiCQ&e=17259,18167&rt=prt.10,ol.251,xjs.301 - DIRECT/216.239.61.104 text/html
1238397620.791 1 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.794 344 192.168.0.5 TCP_MISS/200 390 GET http://www.google-analytics.com/__utm.gif?utmwv=4.3&utmn=24952436&utmhn=yourforkids.com&utmcs=utf-8&utmsr=1024x768&utmsc=32-bit&utmul=en-us&utmje=1&utmfl=6.0%20r79&utmdt=yourforkids.com%20%7C%20Kid%20Movie%20%7C%20Movie%20%7C%20DVD%20%7C%20DVD%20Rental&utmhid=969289685&utmr=-&utmp=/Kid-Movie.html?qs=06oENya4ZGJbLUV9ocEMFx9YsQ_VoINjuLGOIPc-UFrUdgZEEhG9ofUWWZn9k5VlFlHCVta0dCkrY-zaut9tmqPNvVG4deYpn7lqYOhyHmnL3WCl3UADRGqGRS_6aucF2UQWO5iZPnPLyaeoBZZybnWt2nkUzF19A_Z5Pkn7dGQZiJgArYXw6Ie8VWvIAI0J5nf-5w5iGIrqogU5TKOChTfP5tYnxKCRD7krzU,YT0xO0w9S2lkIE1vdmllO1I9NDtTPXQjMi0jQ28.&utmac=UA-2201473-2&utmcc=__utma%3D105188491.3428763974535293400.1238445107.1238445107.1238445107.1%3B%2B__utmz%3D105188491.1238445107.1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B - DIRECT/72.14.235.100 image/gif
1238397620.823 0 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.852 10 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.858 424 192.168.0.5 TCP_MISS/200 427 GET http://us.bc.yahoo.com/b?P=FFc7D2KIcFH5EQhfSc37wNdvdz.IxUnQdPAACLjS&T=13ucc1l2f%2fX%3d1238398192%2fE%3d1635382649%2fR%3dchat%2fK%3d5%2fV%3d1.1%2fW%3dJ%2fY%3dYAHOO%2fF%3d144449464%2fI%3d1%2fS%3d1%2fJ%3d0B718862&U=137i2spv5%2fN%3d9UU1UEwNBlo-%2fC%3d715481.13174281.13345001.42%2fD%3dN%2fB%3d5404760%2fV%3d1&Q=0&O=0.4071068968295436 - DIRECT/68.142.228.136 image/gif
1238397620.882 1 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.912 0 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.919 4454 192.168.0.5 TCP_MISS/200 92057 GET http://www.cartoonnetwork.com/data/_masters/Games.xml?c=530375 - DIRECT/64.236.29.72 application/xml
1238397620.929 494 192.168.0.5 TCP_MISS/200 1440 GET http://ads.cartoonnetwork.com/js.ng/site=toon&toon_pos=160x600_sync&toon_rollup=games&toon_section=container_page&tile=0573718938321 - DIRECT/64.236.29.63 application/x-javascript
1238397620.941 3438 192.168.0.5 TCP_REFRESH_HIT/304 149 GET http://download.im.alisoft.com/aliim/AliIM6_ATM/configs/dailyupdate_u.xml?ver=6.05.10&login_id=enaliintpk100859391 - DIRECT/121.0.30.96 -
1238397620.942 0 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.950 453 192.168.0.5 TCP_HIT/200 869 GET http://static4.orkut.com/img/castro/i_phototag.gif - NONE/- image/gif
1238397620.950 1270 192.168.0.5 TCP_REFRESH_HIT/200 634 GET http://i.cdn.turner.com/toon/games/tools/img/container/gameborder_bottom.jpg - DIRECT/209.84.4.126 image/jpeg
1238397620.972 0 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397620.973 459 192.168.0.5 TCP_MISS/304 208 GET http://outfits.zwinky.com/users/common/defaultfemale.xml - DIRECT/66.235.126.132 -
1238397620.989 538 192.168.0.5 TCP_MISS/200 5856 GET http://ad.yieldmanager.com/st?ad_type=iframe&ad_size=728x90&site=140421&section_code=13174281&cb=1238398195854420&zip=&ycg=m&yyob=1987&pub_redirect_unencoded=1&pub_redirect=http://us.ard.yahoo.com/SIG=15hs4724f/M=715481.13174281.13345001.42/D=chat/S=1635382649:N/Y=YAHOO/EXP=1238405395/L=31idTmKIcFHJS8flSbjU_o2xdz.IxUnQdPMADNfV/B=PaL7TEwNBlM-/J=1238398195854420/K=_d6nvW9JgLgOmrDZwUG1Xw/A=5404760/R=0/* - DIRECT/77.238.172.11 -
1238397621.002 0 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397621.032 2 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397621.051 617 192.168.0.5 TCP_MISS/302 734 GET http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=10&ct=1238398194&rver=5.5.4177.0&wp=MBI&wreply=https:%2F%2Fbyfiles.storage.msn.com%2Fstorageservice%2Fpassport%2Fauth.aspx%3Fsru%3Dhttp:%252f%252fbyfiles.storage.msn.com%252fy1pZVJKbdUxPQn9-n6R4q1WLxhLRa58veY8IgF7XP2r6VFw4MNruUDsiGYieE3qzNpZu446Huo_j7qmleKVerzltg&lc=1033&id=41839 - DIRECT/65.54.186.107 text/html
1238397621.052 618 192.168.0.5 TCP_MISS/200 544 GET http://w88.go.com/b/ss/wdgespcricinfo,wdgespge/1/H.15.1/s68255402034013?[AQB]&ndh=1&t=30/2/2009%2012%3A29%3A55%201%20-300&ns=espn&cdp=2&pageName=cricinfo%3AHomepage%20PAK&g=http%3A//www.cricinfo.com/&cc=USD&ch=cricinfo%3Acricinfo%20homepage&server=www.cricinfo.com&events=event3%2Cevent38&products=ads%3Bfl_nvi_150x140%3B%3B%3Bevent38%3D1%2Cads%3Bnews_hpnp%3B%3B%3Bevent38%3D1%2Cads%3Brss_hpnp%3B%3B%3Bevent38%3D1%2Cads%3Bwidget_hpnp%3B%3B%3Bevent38%3D1%2Cads%3Btalk_hpnp%3B%3B%3Bevent38%3D1%2Cads%3Bfl_combo_hpnp%3B%3B%3Bevent38%3D1%2Cads%3Btw_hpnp%3B%3B%3Bevent38%3D1&c1=cricinfo&h1=cricinfo%3Acricinfo%3Acricinfo%20homepage%3AHomepage%20PAK&c4=homepages&c6=Repeat&v9=en&v11=homepages%3Acricinfo%3Acricinfo%20homepage&c12=cricinfo%3ACricinfo%20-%20New%20Zealand%20v%20India%20-%202nd%20Test%20-%20pak%20scorecard&v12=pk&v13=cricinfo%3AHomepage%20PAK&c16=pk&c17=en&c19=cricinfo%3AHomepage%20PAK&v19=cricket&c24=More%20than%207%20days&c25=cricket&s=1024x768&c=32&j=1.7&v=Y&k=Y&bw=1024&bh=605&p=Mozilla%20Default%20Plug-in%3BRealPlayer(tm)%20G2%20LiveConnect-Enabled%20Plug-In%20(32-bit)%20%3BRealPlayer%20Version%20Plugin%3BMicrosoft%20Office%202003%3BShockwave%20Flash%3BYahoo%20Application%20State%20Plugin%3BJava(TM)%20Platform%20SE%206%20U6%3BMicrosoft�%20DRM%3BWindows%20Media%20Player%20Plug-in%20Dynamic%20Link%20Library%3B&[AQE] - DIRECT/66.235.139.70 image/gif
1238397621.058 564 192.168.0.5 TCP_MISS/206 8531 GET http://msgr.dlservice.microsoft.com/download/5/2/E/52EB299A-E4DE-43E2-8D55-510D7FB03610/en/wlsetup-cvr.exe - DIRECT/87.248.218.175 application/octet-stream
1238397621.062 3 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html
1238397621.082 2774 192.168.0.5 TCP_REFRESH_HIT/200 7997 GET http://img301.imageshack.us/img301/5350/76069cholergz7.jpg - DIRECT/38.99.76.172 image/jpeg
1238397621.092 6 192.168.0.5 TCP_DENIED/400 1481 NONE NONE:// - NONE/- text/html

yeah but the previous post I did was incorrect..
when you ran
/system run script XXXXX

it didn’t run the script at all.. because my syntax was wrong.

you need to run

/system script run XXXXXX

it was my message to you that had an error, I’ve also tried the script on one of my 3.17 boxes and it works fine.

The Script was stuck-up how to debug ? currently using opendns nameserver terminal output

[admin@MikroTik] > /system script run daily-conficker-list
status: connecting
– [Q quit|D dump|C-z pause]
failure: connection failed

Hmm it would seem that your mikrotik is unable to download the files from my webserver.
Does the box you’re using have a default route (0.0.0.0/0) out to the internet?

The script as noted above does work fine on 3.17 which means there is an issue with your mikrotik being able to connect to my server somehow.

mm strange ! anyway i just tweak with this script with my linux box downloaded files on linux box then retrive to local machine. files are http://192.168.0.1/conficker/www.epicwinrar.com/conficker/

after this get sucess but 20% the script now given this error

/system script run daily-conficker-list
status: connecting

status: finished
failure

i checked in files the only 1 file download 03-30-2009.txt


i changed in script marked

:local date [/system clock get date]
:local month [:pick $date 0 3]
:local day [:pick $date 4 6]
:local year [:pick $date 7 11]

#set month to numerical value
:if ([$month] = “jan”) do={ :set month “01” }
:if ([$month] = “feb”) do={ :set month “02” }
:if ([$month] = “mar”) do={ :set month “03” }
:if ([$month] = “apr”) do={ :set month “04” }
:if ([$month] = “may”) do={ :set month “05” }
:if ([$month] = “jun”) do={ :set month “06” }
:if ([$month] = “jul”) do={ :set month “07” }
:if ([$month] = “aug”) do={ :set month “08” }
:if ([$month] = “sep”) do={ :set month “09” }
:if ([$month] = “oct”) do={ :set month “10” }
:if ([$month] = “nov”) do={ :set month “11” }
:if ([$month] = “dec”) do={ :set month “12” }

#download current days domain list
/tool fetch address=192.168.0.1 host=192.168.0.1 mode=http src-path=“conficker/www.epicwinrar.com/conficker/$month-$day-$year.txt
:log info “Download Complete”
:delay 2

#check to ensure todays file exists before deleting yesterdays list
:log info “Begining Address List Modification”
:if ( [/file get [/file find name=“$month-$day-$year.txt”] size] > 0 ) do={

/ip firewall address-list remove [/ip firewall address-list find list=daily-conficker]

:local content [/file get [/file find name=“$month-$day-$year.txt”] contents] ;
:local contentLen [ :len $content ] ;

:local lineEnd 0;
:local line “”;
:local lastEnd 0;

:do {
:set lineEnd [:find $content “\n” $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;

#resolve each new line and add to the address list daily-conficker
:if ( [:pick $line 0 1] != “\n” ) do={
:local entry [:pick $line 0 ($lineEnd ) ]
:if ( [:len $entry ] > 0 ) do={
:local listip [:resolve “$entry”]
:if ($listip != “failure” ) do={
/ip firewall address-list add list=daily-conficker address=$listip
:log info “$listip”
}
}
}
} while ($lineEnd < $contentLen)
}
:log info “Address List Modification Complete”
#cleaning up
/file remove “$month-$day-$year.txt”

If it gets the failure message it means the :resolve has failed and stops the script from continuing (the bug mentioned in my second post)

If you’re using opendns servers (208.67.222.222 208.67.220.220) as your dns servers this should not happen as any invalid requests will instead be returned an opendns address (normally in the 208.67.X.X range)

Thanks Mate

Now its working but i think something wrong. The script add duplicate ips . its fine or something missing in script .
Dude can you do one more thing can you make simple this script. i have also linux box and make script to fatch and export list to the file with crontab just confuse with MT scripting here is my simple script to fatch file from local machine this local machine fatch data from site. conf.txt is located on my server

#download current days domain list
/tool fetch address=192.168.0.1 host=192.168.0.1 mode=http src-path=“conficker/www.epicwinrar.com/conficker/conf.txt
:log info “Download Complete”
:delay 2

#check to ensure todays file exists before deleting yesterdays list
:log info “Begining Address List Modification”
:if ( [/file get [/file find name=conf.txt] size] > 0 ) do={

/ip firewall address-list remove [/ip firewall address-list find list=daily-conficker]

:local content [/file get [/file find name=conf.txt] contents] ;
:local contentLen [ :len $content ] ;

:local lineEnd 0;
:local line “”;
:local lastEnd 0;

:do {
:set lineEnd [:find $content “\n” $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;

#resolve each new line and add to the address list daily-conficker
:if ( [:pick $line 0 1] != “\n” ) do={
:local entry [:pick $line 0 ($lineEnd ) ]
:if ( [:len $entry ] > 0 ) do={
:local listip [:resolve “$entry”]
:if ($listip != “failure” ) do={
/ip firewall address-list add list=daily-conficker address=$listip
:log info “$listip”
}
}
}
} while ($lineEnd < $contentLen)
}
:log info “Address List Modification Complete”
#cleaning up
/file remove conf.txt

This works fine on 3.19 as long as the dns servers are set to opendns as stated above.

Is there any way to prevent duplicate ip addresses from being added to the address list since many of the ips are the same.