วิเคราะห์ Radius ด้วย Pascal | ||
Radius คืออะไร
| root 195 193 0 Oct 27 ? 0:02 /usr/local/etc/radius/bin/radiusd www 5877 199 0 14:30:23 ? 0:00 /usr/local/etc/httpd/httpd www 5821 199 0 13:55:01 ? 0:00 /usr/local/etc/httpd/httpd root 179 1 0 Oct 27 ? 0:00 /usr/lib/sendmail -bd -q1h |
Crontab คือการตั้งเวลาให้โปรแกรมประมวลผล
|
NAME crontab - user crontab file SYNOPSIS crontab [ filename ] crontab [-elr] username DESCRIPTION The crontab utility manages a user's access with cron by copying, creating, listing, and removing crontab files. If invoked without options, crontab copies the specified file, or the standard input if no file is specified, into a direc- tory that holds all users' crontabs. minute (0-59),
เช่น 0 * * * * หมายถึงให้ประมวลผลคำสั่งที่ต่อท้ายนี้ ทุก 0 นาที ก็คือทุกชั่วโมงที่เริ่มต้นชั่วโมง หรือ 59 23 * * * หมายถึงให้ประมวลผลคำสั่งที่ต่อท้ายนี้ ทุก วันเวลา 23 นาฬิกา 59 นาที หรือ 0, 15, 50 * * * * หมายถึงให้ประมวลผลคำสั่งที่ต่อท้ายนี้ ทุก ชั่วโมงละ 3 ครั้งคือที่ 0 นาที 15 นาที หรือ 50 นาทีของแต่ละชั่วโมง
(เราเป็นสถานศึกษาให้บริการศิษย์เก่าแค่ 4 เลขหมาย และภายในสถาบันตามตึกอีก 4 เลขหมายเท่านั้น) ซึ่ง 2 บรรทัดข้างล่างนี้เห็นได้จากการใช้คำสั่ง crontab -l 0 * * * * /usr/local/etc/radius/bin/startup 59 23 * * * /usr/local/etc/radius/bin/runacct |
โปรแกรม startup : run ทุกชั่วโมง อัตโนมัติ
| #!/bin/sh /usr/local/etc/radius/bin/radiusd > /tmp/report /usr/bin/mail webmaster@yonok.ac.th < /tmp/report rm /tmp/report |
โปรแกรม runacct : run วันละ 1 ครั้ง อัตโนมัติ
| #!/bin/sh cp /usr/local/etc/radius/radacct/door.yonok.ac.th/detail /export/home/account/data ###### /usr/bin/date +%d > /tmp/date /usr/bin/date +%m > /tmp/month /usr/bin/date +%y > /tmp/year DATE=`cat /tmp/date` MONTH=`cat /tmp/month` YEAR=`cat /tmp/year` TODAY="$DATE$MONTH$YEAR" cd /export/home/account/data cp detail ../backup mv detail $TODAY ###### cd /tmp rm date month year rm /usr/local/etc/radius/radacct/door.yonok.ac.th/detail #end |
ตัวอย่างผลลัพธ์จาก Radius ที่จะใช้ pascal สรุปผลออกมา
| Tue Feb 1 04:09:07 2000 Client-Id = 203.146.9.254 Client-Port-Id = 2 User-Name = "guest006" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B0D" Tue Feb 1 04:09:12 2000 Client-Id = 203.146.9.254 Client-Port-Id = 2 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B0F" Framed-Protocol = PPP Tue Feb 1 04:09:13 2000 Client-Id = 203.146.9.254 Client-Port-Id = 2 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B0F" Framed-Protocol = PPP Framed-Address = 203.146.9.249 Tue Feb 1 04:28:06 2000 Client-Id = 203.146.9.254 Client-Port-Id = 2 User-Name = "" Acct-Status-Type = Stop User-Service-Type = Framed-User Acct-Session-Id = "00000B0F" Framed-Protocol = PPP Framed-Address = 203.146.9.249 Acct-Session-Time = 1133 Tue Feb 1 04:28:11 2000 Client-Id = 203.146.9.254 Client-Port-Id = 2 User-Name = "guest006" Acct-Status-Type = Stop User-Service-Type = 7 Acct-Session-Id = "00000B0D" Acct-Session-Time = 1144 Tue Feb 1 05:57:02 2000 Client-Id = 203.146.9.254 Client-Port-Id = 7 User-Name = "staff001" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B10" Tue Feb 1 05:57:07 2000 Client-Id = 203.146.9.254 Client-Port-Id = 7 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B12" Framed-Protocol = PPP Tue Feb 1 05:57:08 2000 Client-Id = 203.146.9.254 Client-Port-Id = 7 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B12" Framed-Protocol = PPP Framed-Address = 203.146.9.244 Tue Feb 1 07:22:53 2000 Client-Id = 203.146.9.254 Client-Port-Id = 4 User-Name = "guest007" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B13" Tue Feb 1 07:22:56 2000 Client-Id = 203.146.9.254 Client-Port-Id = 4 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B15" Framed-Protocol = PPP Tue Feb 1 07:22:57 2000 Client-Id = 203.146.9.254 Client-Port-Id = 4 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B15" Framed-Protocol = PPP Framed-Address = 203.146.9.247 Tue Feb 1 07:32:49 2000 Client-Id = 203.146.9.254 Client-Port-Id = 4 User-Name = "" Acct-Status-Type = Stop User-Service-Type = Framed-User Acct-Session-Id = "00000B15" Framed-Protocol = PPP Framed-Address = 203.146.9.247 Acct-Session-Time = 592 Tue Feb 1 07:32:52 2000 Client-Id = 203.146.9.254 Client-Port-Id = 4 User-Name = "guest007" Acct-Status-Type = Stop User-Service-Type = 7 Acct-Session-Id = "00000B13" Acct-Session-Time = 599 Tue Feb 1 07:32:55 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "guest009" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B16" Tue Feb 1 07:33:09 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B18" Framed-Protocol = PPP Tue Feb 1 07:33:09 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B18" Framed-Protocol = PPP Framed-Address = 203.146.9.243 Tue Feb 1 07:36:17 2000 Client-Id = 203.146.9.254 Client-Port-Id = 7 User-Name = "" Acct-Status-Type = Stop User-Service-Type = Framed-User Acct-Session-Id = "00000B12" Framed-Protocol = PPP Framed-Address = 203.146.9.244 Acct-Session-Time = 5950 Tue Feb 1 07:36:22 2000 Client-Id = 203.146.9.254 Client-Port-Id = 7 User-Name = "staff001" Acct-Status-Type = Stop User-Service-Type = 7 Acct-Session-Id = "00000B10" Acct-Session-Time = 5960 Tue Feb 1 07:54:28 2000 Client-Id = 203.146.9.254 Client-Port-Id = 5 User-Name = "guest008" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B19" Tue Feb 1 07:54:32 2000 Client-Id = 203.146.9.254 Client-Port-Id = 5 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B1B" Framed-Protocol = PPP Tue Feb 1 07:54:32 2000 Client-Id = 203.146.9.254 Client-Port-Id = 5 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B1B" Framed-Protocol = PPP Framed-Address = 203.146.9.246 Tue Feb 1 08:05:42 2000 Client-Id = 203.146.9.254 Client-Port-Id = 6 User-Name = "staff011" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B1C" Tue Feb 1 08:05:51 2000 Client-Id = 203.146.9.254 Client-Port-Id = 6 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B1E" Framed-Protocol = PPP Tue Feb 1 08:05:51 2000 Client-Id = 203.146.9.254 Client-Port-Id = 6 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B1E" Framed-Protocol = PPP Framed-Address = 203.146.9.245 Tue Feb 1 08:22:52 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "dorm" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B1F" Tue Feb 1 08:22:56 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B21" Framed-Protocol = PPP Tue Feb 1 08:22:57 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B21" Framed-Protocol = PPP Framed-Address = 203.146.9.248 Tue Feb 1 09:02:16 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "" Acct-Status-Type = Stop User-Service-Type = Framed-User Acct-Session-Id = "00000B18" Framed-Protocol = PPP Framed-Address = 203.146.9.243 Acct-Session-Time = 5347 Tue Feb 1 09:02:19 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "guest009" Acct-Status-Type = Stop User-Service-Type = 7 Acct-Session-Id = "00000B16" Acct-Session-Time = 5364 Tue Feb 1 09:09:24 2000 Client-Id = 203.146.9.254 Client-Port-Id = 5 User-Name = "" Acct-Status-Type = Stop User-Service-Type = Framed-User Acct-Session-Id = "00000B1B" Framed-Protocol = PPP Framed-Address = 203.146.9.246 Acct-Session-Time = 4493 Tue Feb 1 09:09:29 2000 Client-Id = 203.146.9.254 Client-Port-Id = 5 User-Name = "guest008" Acct-Status-Type = Stop User-Service-Type = 7 Acct-Session-Id = "00000B19" Acct-Session-Time = 4501 Tue Feb 1 09:18:51 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "yonok013" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B22" Tue Feb 1 09:18:58 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B24" Framed-Protocol = PPP Tue Feb 1 09:18:59 2000 Client-Id = 203.146.9.254 Client-Port-Id = 8 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B24" Framed-Protocol = PPP Framed-Address = 203.146.9.243 Tue Feb 1 10:15:09 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "" Acct-Status-Type = Stop User-Service-Type = Framed-User Acct-Session-Id = "00000B21" Framed-Protocol = PPP Framed-Address = 203.146.9.248 Acct-Session-Time = 6735 Tue Feb 1 10:15:12 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "dorm" Acct-Status-Type = Stop User-Service-Type = 7 Acct-Session-Id = "00000B1F" Acct-Session-Time = 6742 Tue Feb 1 10:15:36 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "staff009" Acct-Status-Type = Start User-Service-Type = 7 Acct-Session-Id = "00000B25" Tue Feb 1 10:15:41 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "" Acct-Status-Type = Start User-Service-Type = Framed-User Acct-Session-Id = "00000B27" Framed-Protocol = PPP Tue Feb 1 10:15:41 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "" Acct-Status-Type = 3 User-Service-Type = Framed-User Acct-Session-Id = "00000B27" Framed-Protocol = PPP Framed-Address = 203.146.9.248 Tue Feb 1 10:42:04 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "" Acct-Status-Type = Stop User-Service-Type = Framed-User Acct-Session-Id = "00000B27" Framed-Protocol = PPP Framed-Address = 203.146.9.248 Acct-Session-Time = 1583 Tue Feb 1 10:42:07 2000 Client-Id = 203.146.9.254 Client-Port-Id = 3 User-Name = "staff009" Acct-Status-Type = Stop User-Service-Type = 7 Acct-Session-Id = "00000B25" Acct-Session-Time = 1591 |
โปรแกรม router.pas
โปรแกรมนี้ผมเขียนขึ้นเมื่อมกราคมปี 41 เพื่อใช้งาน .. ซึ่งถ้าเขียนใหม่ จะเขียนได้ดีกว่านี้มาก ท่านใดเขียนใหม่แล้ว ลดขั้นตอนลงได้ ช่วยส่งมาด้วยนะครับ ผมจะลง source ให้ครับ
| uses crt; var F : Text; I,err : integer; FOUT : Text; FOUTNAME : String[12]; l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11 : string; ok : integer; kpuser : string[8]; kpport : char; kptimeuse : string[7]; kpdatetime: string[30]; keepdata : string; timesecond,timeminute,timehour,timeall : real; procedure openfileout; begin Assign(F, ParamStr(1)); {$I-} Reset(F); {$I+} if IOResult = 0 then begin FOUTNAME := ParamStr(1) + 'x.txt'; Assign(FOUT, FOUTNAME); Rewrite(FOUT); Writeln('File name is : ',Paramstr(1)); end else Writeln('File not found'); end; procedure readuntilfound; var getline : string; getch : char; begin ok := 0; getch := char(0); getline := ''; l1 :=''; l3:=''; l4:=''; l5 := ''; l8:=''; readln(f, getline); if getline[1] <> char(9) then l1 := getline; readln(f, getline); l2 := getline; readln(f, getline); l3 := getline; readln(f, getline); l4 := getline; readln(f, getline); l5 := getline; readln(f, getline); l6 := getline; readln(f, getline); l7 := getline; readln(f, getline); if length(getline) < 5 then exit; l8 := getline; if (l5[21]+l5[22]+l5[23]+l5[24] = 'Stop') and (l6[22] = '7') then begin ok := 1; kpdatetime := l1; kpport := l3[19]; kpuser := l4[15]+l4[16]+l4[17]+l4[18]+l4[19]+l4[20]+l4[21]+l4[22]; kptimeuse := ''; for I := 22 to length(l8) do begin if l8[i] in ['0','1','2','3','4','5','6','7','8','9'] then kptimeuse := kptimeuse + l8[i] end; val(kptimeuse,timeall,err); keepdata := kpuser+' '+kpport+' '+kpdatetime+' '+kptimeuse; keepdata := keepdata + char(13) + char(10); write(keepdata); end; readln(f, getline); if length(getline) < 5 then exit; l9 := getline; readln(f, getline); if length(getline) < 5 then exit; l10 := getline; readln(f, getline); if length(getline) < 5 then exit; l11 := getline; writeln(getline); readln; end; procedure keepinfile; begin write(fout,keepdata); end; begin clrscr; if length(paramstr(1)) > 0 then begin openfileout; while not eof(f) do begin readuntilfound; if ok = 1 then keepinfile; end; close(fout); end else Writeln('What is the input-file.') end. routera3 5 Fri Aug 1 01:21:12 1997 3075 routera1 8 Fri Aug 1 01:36:06 1997 13256 routera1 5 Fri Aug 1 02:10:44 1997 1554 routera3 5 Fri Aug 1 08:12:32 1997 964 routera1 8 Fri Aug 1 08:23:53 1997 2408 routera1 5 Fri Aug 1 08:25:39 1997 599 routera1 5 Fri Aug 1 08:48:50 1997 1302 routera1 5 Fri Aug 1 08:49:48 1997 31 routera1 5 Fri Aug 1 08:51:46 1997 80 routera1 8 Fri Aug 1 09:26:15 1997 3037 routera1 5 Fri Aug 1 09:51:03 1997 3200 routera2 3 Fri Aug 1 09:57:49 1997 77 routera2 3 Fri Aug 1 10:00:06 1997 106 routera1 5 Fri Aug 1 10:19:54 1997 1555 routera1 5 Fri Aug 1 10:26:49 1997 190 routera1 5 Fri Aug 1 10:41:48 1997 808 routera1 5 Fri Aug 1 10:51:14 1997 236 routera1 3 Fri Aug 1 10:52:08 1997 104 routera1 3 Fri Aug 1 10:53:36 1997 30 routera1 5 Fri Aug 1 11:13:36 1997 690 routera3 8 Fri Aug 1 11:15:11 1997 6391 routera1 5 Fri Aug 1 11:15:17 1997 30 routera1 5 Fri Aug 1 11:28:22 1997 125 |
ทำรายงานใน excel |
|
ตัวอย่าง Config ของ Cisco 2500 ที่ผมเคยใช้
| Username: romeo Password: yonok-router>en Password: yonok-router#show run Building configuration... Current configuration : 2140 bytes ! version 12.2 service timestamps debug uptime service timestamps log uptime service password-encryption service udp-small-servers service tcp-small-servers ! hostname yonok-router ! aaa new-model ! aaa session-id common enable secret 5 $1$FKQT$u.xb5Wxpxk5GN6e2.uwYH/ enable password 7 095F43080B11 ! username wichep password 7 05181F1C354943 username burin password 7 01111450085C535F70 username suwit password 7 045A0F0B062F ip subnet-zero ! interface FastEthernet0/0 ip address 202.29.78.254 255.255.255.0 speed auto full-duplex no cdp enable ! interface Serial0/0 ip address 202.28.202.74 255.255.255.252 ip access-group 102 in ip access-group 101 out no cdp enable ! router igrp 1 redistribute connected network 202.28.29.0 network 202.29.78.0 ! ip classless ip route 0.0.0.0 0.0.0.0 Serial0/0 ip route 0.0.0.0 0.0.0.0 202.28.202.73 no ip http server ip pim bidir-enable ! access-list 101 deny tcp host 202.29.78.9 any eq 5000 access-list 101 deny tcp host 202.29.78.9 any eq 6900 access-list 101 deny tcp host 202.29.78.18 any eq 5000 access-list 101 deny tcp host 202.29.78.18 any eq 6900 access-list 101 permit ip any any access-list 102 deny tcp any 202.29.78.0 0.0.0.255 eq 135 access-list 102 deny udp any 202.29.78.0 0.0.0.255 eq 135 access-list 102 permit ip any any access-list 102 deny tcp any 202.29.78.0 0.0.0.255 eq 134 access-list 102 deny udp any 202.29.78.0 0.0.0.255 eq 134 access-list 103 deny tcp host 202.29.78.18 any eq ftp access-list 103 deny tcp host 202.29.78.18 any gt 2000 access-list 103 permit ip any any dialer-list 1 protocol ip permit dialer-list 1 protocol ipx permit no cdp run snmp-server community public RO banner login ^CC *********************************************************** * YONOK COLLEGE * * Tel.0-5465-170 * * www.yonok.ac.th, www.isinthai.com * *********************************************************** ^C ! line con 0 line aux 0 line vty 0 4 password 7 071C385F5A0C14 ! end yonok-router# |