Changeset 7474 for modules/branches/2.5
- Timestamp:
- 03/10/09 17:29:05 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/weakpasswords/functions.inc.php
r7473 r7474 26 26 $weak = weakpasswords_get_users(); 27 27 if(sizeof($weak) > 0) { 28 foreach($weak as $device => $message) { 29 $nt->add_security("weakpasswords", $device, "Weak secret for device $device: $message"); 28 foreach($weak as $details) { 29 $extended_text = "Warning: The use of SIP/IAX passwords that are weak can allow hackers to make brute force registrations and possibly make calls through your PBX. It is strongly recommended, you choose strong secrets.".$details['deviceortrunk']." ".$details['name']." has a weak secret of ".$details['secret'].": ".$details['message']; 30 $nt->add_security("weakpasswords", $details['name'], $details['deviceortrunk']." ".$details['name'].": ".$details['message'],$extended_text); 30 31 } 31 32 … … 38 39 global $db; 39 40 40 $sql = "SELECT id as device,data as secret FROM sip WHEREkeyword='secret'";41 $sql = "SELECT 'SIP' as tech,s.id as id, s2.data as device,s.data as secret FROM sip s LEFT JOIN sip s2 ON s.id=s2.id AND s2.keyword='account' WHERE s.keyword='secret'"; 41 42 $sipsecrets = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 43 $sql = "SELECT 'IAX' as tech,s.id as id, s2.data as device,s.data as secret FROM iax s LEFT JOIN iax s2 ON s.id=s2.id AND s2.keyword='account' WHERE s.keyword='secret'"; 44 $iaxsecrets = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 45 $secrets = array_merge($sipsecrets,$iaxsecrets); 42 46 $weak = array(); 43 foreach($sipsecrets as $sip) { 44 $device = $sip['device']; 45 $secret = $sip['secret']; 47 foreach($secrets as $arr) { 48 $name = $arr['device']; 49 $id = $arr['id']; 50 $secret = $arr['secret']; 51 $tech = $arr['tech']; 46 52 53 if($id == $name) { 54 $deviceortrunk = "Extension/Device"; 55 } 56 else { 57 $deviceortrunk = "$tech Trunk"; 58 } 47 59 $reversed = strrev($secret); 48 60 $match = "0123456789"; 49 61 if(strpos($match,$secret) || strpos($match,$reversed)) { 50 $weak[ $device] = "Secret $secret has sequential digits";62 $weak[] = array("deviceortrunk" => $deviceortrunk, "name" => $name, "message" => "Secret has sequential digits", "secret" => $secret); 51 63 } 52 64 else if($device == $secret) { 53 $weak[ $device] = "Secret $secret is same as device";65 $weak[] = array("deviceortrunk" => $deviceortrunk, "name" => $name, "message" => "Secret same as device", "secret" => $secret); 54 66 } 55 67 else if(preg_match("/(.)\\1{3,}/",$secret,$regs)) { 56 $weak[ $device] = "Secret $secret contains consecutive digit ".$regs[1];68 $weak[] = array("deviceortrunk" => $deviceortrunk, "name" => $name, "message" => "Secret has consecutive digit ".$regs[1], "secret" => $secret); 57 69 } 58 70 else if(strlen($secret) < 6) { 59 $weak[ $device] = "Secret $secret is less than 6 digits long";71 $weak[] = array("deviceortrunk" => $deviceortrunk, "name" => $name, "message" => "Secret less than 6 digits", "secret" => $secret); 60 72 } 61 73 } modules/branches/2.5/weakpasswords/page.weakpasswords.php
r7473 r7474 12 12 //GNU General Public License for more details. 13 13 14 //Both of these are used for switch on config.php 14 15 $display = isset($_REQUEST['display'])?$_REQUEST['display']:'weakpasswords'; 16 17 $action = isset($_REQUEST['action'])?$_REQUEST['action']:''; 18 $email = isset($_REQUEST['email'])?$_REQUEST['email']:''; 15 19 16 20 ?> … … 20 24 <? 21 25 22 echo "<table><tr><td><div class='content'><h2>"._("Weak Password Detection")."</h2></span></td></tr>\n"; 26 echo "<table cellpadding=5><tr><td colspan=3><div class='content'><h2>"._("Weak Password Detection")."</h2></span></td></tr>\n"; 27 echo "<tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Secret</b></td><td><b>Message</b></td></tr>"; 23 28 ?> 24 <tr>25 <td valign="top">26 27 29 <?php 28 30 if (is_null($selected)) $selected = array(); 29 31 $weak = weakpasswords_get_users(); 30 32 if(sizeof($weak) > 0) { 31 foreach ($weak as $de vice => $message) {32 echo "Device $device: $message<br>";33 foreach ($weak as $details) { 34 echo '<tr><td>'.$details['deviceortrunk'].'</td><td>'.$details['name'].'</td><td>'.$details['secret'].'</td><td>'.$details['message']."</td></tr>"; 33 35 34 36 } 35 37 } 36 38 else { 37 echo " No weak secrets detected on this system.";39 echo "<tr><td colspan=3>No weak secrets detected on this system.</td></tr>"; 38 40 } 39 41 ?> 40 </td></tr>41 42 42 43 <?php
