Advertisement
c0mad0r

ldap login report

Jun 14th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 20.40 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. #This script uses awk to find all successful"err=0" queries and
  4. #prints the previous line (getline) for $LOGS |
  5. #then greps for the word "BIND" | then grep -v excludes unwanted queries |
  6. #then uses sed to ONLY get the uid name after uid= and before ou= |
  7. #then uses awk to do the equivalent of sort -n | uniq -c |sort -rn
  8. #at the end of the line | then sorts alphabetically
  9.  
  10. # Written by TVK 2015/07/27 - v 1.0
  11. # - Modified find, refined grep, added service var.
  12. # Updated by TVK 2015/10/28 - v 1.2
  13. # - Changed html layout, added IP0/49 finds.
  14. # Updated by TVK 2016/06/01 - v 1.3
  15. # - Modified HTML+CSS for GMail & Outlook form compatibility, Added HTML as attachment
  16. # Updated by TVK 2019/05/22 - v 1.4
  17. # - Added LDAP AUTH via 389 statement
  18. # - Shortened search quieries: https://stackoverflow.com/questions/56248792/
  19.  
  20. # SOURCES
  21. # http://stackoverflow.com/questions/3317174/sending-html-mail-using-a-shell-script
  22. # http://www.unix.com/shell-programming-and-scripting/222753-sendmail-header-footer-logo-html-body.html
  23. # http://linuxcommand.org/wss0030.php
  24. # http://unix.stackexchange.com/questions/102092/mail-send-email-with-attachment-from-commandline
  25. # http://stackoverflow.com/questions/17359/how-do-i-send-a-file-as-an-email-attachment-using-linux-command-line
  26.  
  27. #Source bashrc
  28. if [ -f /etc/bashrc ]; then
  29.         . /etc/bashrc
  30. fi
  31.  
  32. ##########################
  33. #   SET VARIABLES    #
  34. ##########################
  35.  
  36. DATE="$(date +%Y-%m-%d)"
  37. TIME="$(date +%r)"
  38. LOGS="/log_dump/ldap/c*"
  39. Auth0="/log_dump/ldapreport/getbinds.txt"
  40. Auth49="/log_dump/ldapreport/getbindfails.txt"
  41. IPAuth0="/log_dump/ldapreport/ipauth0.txt"
  42. IPAuth49="/log_dump/ldapreport/ipauth49.txt"
  43. Auth389="/log_dump/ldapreport/ldap389.txt"
  44. Alumni="/log_dump/ldapreport/StudentAlumUSDLdapUsage.csv"
  45. NoAlumni="/log_dump/ldapreport/StudentAlumnotFound.txt"
  46. ServAcct="helpdes[a-z]*|svc-*|mptest[0-9]-*|sites|marketing|housing|testaccount|magent"
  47. EMAILBODY="/log_dump/ldapreport/emailbody.html"
  48. FROM="fromuser@site.com"
  49. TO="touser@site.com"
  50. SUBJECT="Monthly LDAP Authentication Summary"
  51. SENT="$(date)"
  52. MAILPART=`uuidgen`
  53. MAILPART_BODY=`uuidgen`
  54.  
  55. export PATH=$PATH:/log_dump/ldapscripts:/opt/apps/home/sunone/Installer/jdk1.6.0_31/jre/bin
  56. export CLASSPATH=/log_dump/ldapscripts/
  57. export JAVA_BIN_DIR=/opt/apps/home/sunone/Installer/jdk1.6.0_31/jre/bin/
  58.  
  59. ##########################
  60. #   CLEANUP OLD  #
  61. ##########################
  62.  
  63. # Collect runtime of script start
  64. START="$(date +"%s")"
  65. sleep 1;
  66.  
  67. # Move old emailbody and create new
  68. [[ -f $EMAILBODY ]] && mv "$EMAILBODY" "$EMAILBODY.bak"
  69. [[ ! -e "$EMAILBODY" ]] && touch "$EMAILBODY"
  70.  
  71. # Move old email attachment and create new
  72. [[ -f catout.out ]] && mv "catout.out" "catout.out.bak"
  73. [[ ! -e "catout.out" ]] && touch "catout.out"
  74.  
  75. # Move or Delete old getbinds and StudentAlums
  76. [[ -f $Auth0 ]] && mv "$Auth0" "$Auth0.bak"
  77. [[ ! -e "$Auth0" ]] && touch "$Auth0"
  78. [[ -f $Auth49 ]] && mv "$Auth49" "$Auth49.bak"
  79. [[ ! -e "$Auth49" ]] && touch "$Auth49"
  80.  
  81. # Move old auth and create new
  82. [[ -f $IPAuth0 ]] && mv "$IPAuth0" "$IPAuth0.bak"
  83. [[ ! -e "$IPAuth0" ]] && touch "$IPAuth0"
  84. [[ -f $IPAuth49 ]] && mv "$IPAuth49" "$IPAuth49.bak"
  85. [[ ! -e "$IPAuth49" ]] && touch "$IPAuth49"
  86. [[ -f $Auth389 ]] && mv "$Auth389" "$Auth389.bak"
  87. [[ ! -e "$Auth389" ]] && touch "$Auth389"
  88.  
  89. # Move old StudentAlumUSDLdapUsage and create new
  90. [[ -f $Alumni ]] && mv "$Alumni" "$Alumni.bak"
  91. [[ ! -e "$Alumni" ]] && touch "$Alumni"
  92. [[ -f $NoAlumni ]] && mv "$NoAlumni" "$NoAlumni.bak"
  93. [[ ! -e "$NoAlumni" ]] && touch "$NoAlumni"
  94.  
  95. # Delete LDAP logs older than 93 days
  96. find /log_dump/ldap -mtime +93 -name "c*" -exec rm -f {} \; &&
  97.  
  98. ##########################
  99. # GET LOGINS STATISTICS  #
  100. ##########################
  101.  
  102. #Get successful BIND 0 logins
  103. #
  104. #Find all logs older than 30 days |
  105. #Grab the line before word "RESULT err=0 tag-97" |
  106. #Grab word "BIND" | sed get the word starting after uid= and before "," |
  107. #Sed remove all blank lines | sed add a "," comma after each |
  108. #Awk sort all uniquely | sort by the 2nd column numbers
  109. #
  110. # tag=97    A result from a client bind operation.
  111. # err=0     SUCCESS LOGIN
  112. # err=49    FAILURE LOGIN
  113.  
  114. [[ -f /tmp/logextract ]] && rm -f "/tmp/logextract"
  115. AuthTemp=$(mktemp -t logextract) || {
  116.     echo "Error creating temp file" >&2
  117.     exit 1
  118. }
  119. find $LOGS -mtime -30 -type f -exec grep -B 2 -Ew "RESULT err=(0|49) tag=97" {} + >"$AuthTemp"
  120. # GET SUCCESS BIND LOGINS
  121. grep -B 2 -w "RESULT err=0 tag=97" "$AuthTemp" | grep -w "BIND" | sed '/uid=/!d;s//&\n/;s/.*\n//;:a;/,/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $Auth0;
  122. # GET FAILED BIND LOGINS
  123. grep -B 2 -w "RESULT err=49 tag=97" "$AuthTemp" | grep -w "BIND" | sed '/uid=/!d;s//&\n/;s/.*\n//;:a;/,/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $Auth49;
  124. # GET SUCCESS BIND LOGIN IPs
  125. grep -B 2 -w "RESULT err=0 tag=97" "$AuthTemp" | grep -E "BIND|LDAP connection from" | sed '/from /!d;s//&\n/;s/.*\n//;:a;/:/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $IPAuth0;
  126. # Get FAILED BIND LOGIN IPs
  127. grep -B 2 -w "RESULT err=49 tag=97" "$AuthTemp" | grep -E "BIND|LDAP connection from" | sed '/from /!d;s//&\n/;s/.*\n//;:a;/:/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $IPAuth49;
  128. # Get INSECURE BIND LOGIN LDAP TCP/389
  129. grep -B 2 -w "LDAP connection from" "$AuthTemp" | grep -E 'LDAP connection from*' | sed '/from /!d;s//&\n/;s/.*\n//;:a;/:/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $Auth389;
  130.  
  131. ##########################
  132. # GET STUDENT STATISTICS #
  133. ##########################
  134.  
  135. $JAVA_BIN_DIR\java LDAPStuAlumBind_linux
  136. sleep 500;
  137.  
  138. ##########################
  139. #   GENERATE FUNCTIONS   #
  140. ##########################
  141.  
  142. function SUCC1
  143. {
  144.     # Total number of all successful real user logins
  145.     cat $Auth0 | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  146. }
  147.  
  148. function SUCC2
  149. {  
  150.     # Total number of all successful service account logins
  151.     cat $Auth0 | grep -Ew $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  152. }
  153.  
  154. function FAIL1
  155. {  
  156.     # Total number of all failed real user logins
  157.     FAIL1A="$(cat $Auth49 | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' )";
  158.     if [ -z "$FAIL1A" ]
  159.         then
  160.         echo "0"
  161.         else
  162.         FAIL1A1="$(echo $FAIL1A | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
  163.         echo $FAIL1A1
  164.     fi
  165. }
  166.  
  167. function FAIL2
  168. {
  169.     # Total number of all failed service account logins
  170.     FAIL2A="$(cat $Auth49 | grep -Ew $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' )";
  171.     if [ -z "$FAIL2A" ]
  172.     then
  173.                 echo "0"
  174.     else
  175.         FAIL2A0="$(echo $FAIL2A | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
  176.                 echo "$FAIL2A0"
  177.     fi
  178. }
  179.  
  180. function TOTL1
  181. {
  182.     # Total count of all real user account logins
  183.     cat $Auth0 | grep -Ev $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  184. }
  185.  
  186. function TOTL2
  187. {
  188.     # Total count of all service account logins
  189.     cat $Auth0 | grep -Ew $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  190. }
  191.  
  192. ##########################
  193. # GENERATE STUDENT STATS #
  194. ##########################
  195.  
  196. function STUDS1
  197. {
  198.     # Total number of all successful student logins
  199.     cat $Alumni | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  200. }
  201.  
  202. function STUDS2
  203. {
  204.     # Total Unique student account logins
  205.     cat $Alumni | grep -Ev $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  206. }
  207.  
  208. function STAFF1
  209. {
  210.     # Total number of all Faculty & Staff logins
  211.     cat $NoAlumni | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  212. }
  213.  
  214. function STAFF2
  215. {
  216.     # Total Unique Faculty & Staff logins
  217.     cat $NoAlumni | grep -Ev $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
  218. }
  219.  
  220. function TOP10S
  221. {
  222.     # Top 10 successful user logins
  223.     echo "<pre>"
  224.     cat $Auth0 | grep -Ev $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
  225.     echo "</pre>"
  226. }
  227.  
  228. function TOP10F
  229. {
  230.     # Top 10 failed user logins
  231.     echo "<pre>"
  232.     cat $Auth49 | grep -Ev $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
  233.     echo "&nbsp;"
  234.     echo "</pre>"
  235. }
  236.  
  237. function TOP10SS
  238. {
  239.     # Top 10 successful service logins
  240.     echo "<pre>"
  241.     cat $Auth0 | grep -Ew $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
  242.     echo "&nbsp;"
  243.     echo "</pre>"
  244. }
  245.  
  246. function TOP10FS
  247. {
  248.     # Top 10 failed service logins
  249.     echo "<pre>"
  250.     cat $Auth49 | grep -Ew $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
  251.     echo "&nbsp;"
  252.     echo "</pre>"
  253. }
  254.  
  255. ##########################
  256. # GENERATE DEST IP STATS #
  257. ##########################
  258.  
  259. function TOP10IPS
  260. {
  261.     # Top 10 IPs where login is successful from
  262.     echo "<pre>"
  263.     tail -n 10 $IPAuth0 | sed 's/\\n/\n/g' | tac
  264.     echo "&nbsp;"
  265.     echo "</pre>"
  266. }
  267.  
  268. function TOP10IPF
  269. {
  270.     # Top 10 IPs where login is failed from
  271.     echo "<pre>"
  272.     tail -n 10 $IPAuth49 | sed 's/\\n/\n/g' | tac
  273.     echo "&nbsp;"
  274.     echo "</pre>"
  275. }
  276.  
  277. function TOP30Auth389
  278. {
  279.         # Top 30 FROM LDAP 389
  280.         echo "<pre>"
  281.         tail -n 30 $Auth389 | sed 's/\\n/\n/g' | tac
  282.         echo "&nbsp;"
  283.         echo "</pre>"
  284. }
  285.  
  286.  
  287. ##########################
  288. #   ENDING SCRIPT TIME   #
  289. ##########################
  290.  
  291. # Get end runtime of script
  292. END="$(date +"%s")"
  293. # Get total runtime in seconds
  294. DIFF="$(($END-$START))"
  295. # Total runtime in minutes
  296. RUNTIME="$(echo "Total Script runtime: $(($DIFF / 60)) minutes and $(($DIFF % 60)) seconds.")"
  297.  
  298. #######################
  299. # GENERATE EMAIL BODY #
  300. #######################
  301.  
  302. spacer=----------------------------
  303. HEADERIMG=$LDPATH/Header.jpg
  304. HEADER="Monthly LDAP Summary Ending on $DATE"
  305. TITLE="Monthly LDAP Summary"
  306.  
  307. (cat <<- _EOF_
  308. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  309. <html xmlns="http://www.w3.org/1999/xhtml">
  310. <head>
  311. <title>$TITLE</title>
  312. <meta http-equiv="Content-Type" content="text/html; charset=unicode">
  313. </head>
  314. <body><p>
  315. </head>
  316.         <style type='text/css'>
  317.          table  {
  318.             width: 100%;
  319.             margin: 0px;
  320.             padding: 0px;
  321.          }
  322.  
  323.          tr:nth-child(even) {
  324.                background-color: #e5e5e5;
  325.          }
  326.  
  327.          td {
  328.                vertical-align: top;
  329.                font-family: Tahoma, Sans-Serif;
  330.                font-size: 11pt;
  331.                padding: 0px;
  332.          }
  333.  
  334.          th {
  335.                vertical-align: top;  
  336.                color: #000000;
  337.                text-align: left;
  338.                font-family: Tahoma, Sans-Serif;
  339.                font-size: 11pt;
  340.          }
  341.          .pluginContent td { padding: 5px; }
  342.  
  343.          .warning { background: #FFFBAA !important }
  344.             .critical { background: #FFDDDD !important }
  345.       </style>
  346.     <body style="padding: 0 10px; font-family:Arial, Helvetica, Sans-Serif; ">
  347.       <a name="top" />
  348.         <table width='100%' style='background-color: white; margin: 0; padding: 0;'>
  349.          <tr>
  350.             <td style='background-color: white; font-size: 2pt;'>
  351.                <img src=https://www.sandiego.edu/brand/images/logos/master-primary/usd-logo-primary-2c.png alt=' USD LDAP Auth Summary' />
  352.             </td>
  353.          </tr>
  354.       </table>
  355.       <div style='height: 10px; font-size: 10px;'>&nbsp;</div>
  356.       <table width='100%'><tr><td style='vertical-align: middle; text-indent: 10px; font-family: Tahoma, Sans-Serif; font-weight: bold; font-size: 14pt; color: #000000;'>$HEADER</td></tr></table>
  357.     <div>
  358.     <hr size="8" color="#002868">
  359.  
  360. <table width='100%' style='padding: 0px; border-collapse: collapse; font-family:Arial,Helvetica,Sans-Serif; border-collapse; word-break:normal; vertical-align:middle;'>
  361.   <tr>
  362.     <th colspan="4" style='font-weight:bold; font-size:28px; background-color:#008dd6; color:#FFFFFF; text-align:center; padding:1px 1px; border-style:solid; border:1px solid #008DD6; border-width:1px;'>ACCOUNT LOGIN INFORMATION</th>
  363.   </tr>
  364.   <tr style='border-bottom: 1px solid #E0E0E0;'>
  365.     <td style='font-weight:bold; font-size:20px; text-align:right;'></td>
  366.     <td style='font-weight:bold; font-size:20px; text-align:right;'>Successful Logins</td>
  367.     <td style='font-weight:bold; font-size:20px; text-align:right;'>Failed Logins</td>
  368.     <td style='font-weight:bold; font-size:20px; text-align:right;'>Unique Accounts</td>
  369.   </tr>
  370.   <tr style='border-bottom: 1px solid #E0E0E0;'>
  371.     <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Student Logins</td>
  372.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STUDS1)</td>
  373.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>N/A</td>
  374.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STUDS2)</td>
  375.   </tr>
  376.   <tr style='border-bottom: 1px solid #E0E0E0;'>
  377.     <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Fac-Staff Logins</td>
  378.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STAFF1)</td>
  379.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>N/A</td>
  380.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STAFF2)</td>
  381.   </tr>
  382.   <tr style='border-bottom: 1px solid #E0E0E0;'>
  383.     <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Total User Logins</td>
  384.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(SUCC1)</td>
  385.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(FAIL1)</td>
  386.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(TOTL1)</td>
  387.   </tr>
  388.   <tr>
  389.     <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Service Accounts</td>
  390.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(SUCC2)</td>
  391.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(FAIL2)</td>
  392.     <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(TOTL2)</td>
  393.   </tr>
  394. </table>
  395.  
  396. <table width='100%'>
  397.     <tr>
  398.     <td style='vertical-align: middle; text-indent: 10px; font-family: Tahoma, Sans-Serif; font-weight: bold; font-size: 12pt; color: #000000;'>&nbsp;</td>
  399.     </tr>
  400. </table>
  401.  
  402. <table width='100%' style='font-family:Arial,Helvetica,Sans-Serif; border-collapse:collapse; border-spacing:0; border:1px solid transparent; word-break:normal; vertical-align:middle;'>
  403.   <tr>
  404.     <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#BAFFBA; padding:1px 1px; border:1px solid transparent;'>TOP 10 LOGINS - USER</th>
  405.     <th width='2%' rowspan="2" style='font-size:14px; vertical-align:inherit; border:1px solid transparent; background-color:transparent; color:transparent;'></th>
  406.     <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#FFBABA; padding:1px 1px; border:1px solid transparent;'>TOP 10 FAILED - USER</th>
  407.   </tr>
  408.   <tr>
  409.     <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10S)</td>
  410.     <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10F)</td>
  411.   </tr>
  412. </table>
  413.  
  414. <table width='100%' style='font-family:Arial,Helvetica,Sans-Serif; border-collapse:collapse; border-spacing:0; border:1px solid transparent; word-break:normal; vertical-align:middle;'>
  415.   <tr>
  416.     <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#BAFFBA; padding:1px 1px; border:1px solid transparent;'>TOP 10 LOGINS - ServAcct</th>
  417.     <th width='2%' rowspan="2" style='font-size:14px; vertical-align:inherit; border:1px solid transparent; background-color:transparent; color:transparent;'></th>
  418.     <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#FFBABA; padding:1px 1px; border:1px solid transparent;'>TOP 10 FAILED - ServAcct </th>
  419.   </tr>
  420.   <tr>
  421.     <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10SS)</td>
  422.     <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10FS)</td>
  423.   </tr>
  424. </table>
  425.  
  426. <table width='100%' style='font-family:Arial,Helvetica,Sans-Serif; border-collapse:collapse; border-spacing:0; border:1px solid transparent; word-break:normal; vertical-align:middle;'>
  427.   <tr>
  428.     <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#BAFFBA; padding:1px 1px; border:1px solid transparent;'>TOP 10 SOURCE IP</th>
  429.     <th width='2%' rowspan="2" style='font-size:14px; vertical-align:inherit; border:1px solid transparent; background-color:transparent; color:transparent;'></th>
  430.     <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#FFBABA; padding:1px 1px; border:1px solid transparent;'>TOP 10 FAILED SOURCE IP</th>
  431.   </tr>
  432.   <tr>
  433.     <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border:1px solid transparent;'>$(TOP10IPS)</td>
  434.     <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border:1px solid transparent;'>$(TOP10IPF)</td>
  435.   </tr>
  436. </table>
  437.  
  438. <table width='100%' style='padding: 0px; table-layout:fixed; border-collapse: collapse;'>
  439.   <tr>
  440.         <th colspan="4" style='font-weight:bold; font-size:14pt; background-color:#008DD6; color:#FFBABA; text-align:center; padding:1px 1px; border-style:solid; border-width:1px; border:1px solid;'>TOP 30 SERVERS USING INSECURE LDAP 389</th>
  441.   </tr>
  442.   <tr>
  443.     <td style='word-wrap:break-word; margin:0px; color:#000000; valign="top" style='font-size:14px; color:#000000; background-color:transparent; border:1px solid transparent;'>$(TOP30Auth389)</td>
  444.   </tr>
  445. </table>
  446.  
  447. <table width='100%' style='padding: 0px; border-collapse: collapse;'>
  448.   <tr>
  449.     <th colspan="4" style='font-weight:bold; font-size:14pt; background-color: #008DD6; color:#E1E1E1; text-align:center; padding:1px 1px; border-style:solid; border-width:1px; border:1px solid #008DD6;'>SCRIPT RUNTIME</td>
  450.   </tr>
  451.   <tr>
  452.     <td style='margin:0px; color:#000000; font-style:italic; font-size:12pt; text-indent:10px; vertical-align:middle;'>$RUNTIME</td>
  453.   </tr>
  454.     <td style='margin:0px; color:#000000; font-style:italic; font-size:12pt; text-indent:49px; vertical-align:middle;'>Completed at: $TIME</td>
  455.   </tr>
  456. </table>
  457. </div>
  458.    <!-- CustomHTMLClose -->
  459. <div style='height: 10px; font-size: 10px;'>&nbsp;</div>
  460. <table width='100%'>
  461.   <tr>
  462.     <td style='font-size:9pt; height: 25px; text-align: center; vertical-align: middle; color: #000000;'>Written by TVK, Systems Architect, University of , number</td>
  463.   </tr>
  464. </table>
  465.    </body>
  466. </p>
  467. </html>
  468. _EOF_
  469. echo "";
  470. ) > $EMAILBODY
  471.  
  472. ##########################
  473. #   CREATE E-MAIL    #
  474. ##########################
  475.  
  476. (
  477. echo "From: $FROM"
  478. echo "Sent: $SENT"
  479. echo "To: $TO"
  480. echo "Subject: $SUBJECT"
  481. echo "MIME-Version: 1.0"
  482. echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
  483. echo ""
  484. echo "--$MAILPART"
  485. echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
  486. echo ""
  487. echo "--$MAILPART_BODY"
  488. echo "Content-Type: text/plain; charset=ISO-8859-1"
  489. echo "You need to enable HTML option for email"
  490. echo "--$MAILPART_BODY"
  491. echo "Content-Type: text/html; charset=UTF-8"
  492. echo "Content-transfer-encoding: us-ascii"
  493. echo "Content-Disposition: inline"
  494. cat $EMAILBODY
  495. echo "--$MAILPART"
  496. echo 'Content-Type: text/csv; name="'$(basename $Alumni)'"'
  497. echo "Content-Transfer-Encoding: uuencode"
  498. echo 'Content-Disposition: attachment; filename="'$(basename $Alumni)'"'
  499. echo ""
  500.  
  501. (uuencode $Alumni $(basename $Alumni))
  502. echo "--$MAILPART--"
  503. ) > catout.out
  504.  
  505. ##########################
  506. #      SEND E-MAIL   #
  507. ##########################
  508.  
  509. cat catout.out | /usr/sbin/sendmail $TO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement