33986238e23400ebad6b51d626f4f765df94c6d2
bernd input-filtering

bernd authored 16 years ago

1) <?php
2) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

3) require_once('inc/error.php');
4) 
bernd input-filtering

bernd authored 16 years ago

5) 
bernd * Passwörter mit cracklib p...

bernd authored 16 years ago

6) function strong_password($password)
7) {
8)   include("config.php");
9)   DEBUG("Öffne Wörterbuch: {$config['cracklib_dict']}");
10)   if (! ($dict = crack_opendict($config['cracklib_dict'])))
11)   {
12)     logger("inc/security.php", "cracklib", "could not open cracklib-dictionary »{$config['cracklib_dict']}«");
13)     system_failure("Kann Crack-Lib-Wörterbuch nicht öffnen: {$config['cracklib_dict']}");
14)   }
15)   // Führe eine Überprüfung des Passworts durch
16)   $check = crack_check($dict, $password);
17) 
18)   $message = crack_getlastmessage();
19)   crack_closedict($dict);
20) 
21)   if ($check === True)
22)   {
23)     DEBUG("Passwort ok");
24)     return true;
25)   }
26)   else
27)   {
28)     DEBUG("Passwort nicht ok: {$message}");
29)     return $message;
30)   }
31) }
32) 
33) 
bernd input-filtering

bernd authored 16 years ago

34) function filter_input_general( $input )
35) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

36)   return htmlspecialchars(iconv('UTF-8', 'UTF-8', $input), ENT_QUOTES, 'UTF-8');
37) }
38) 
39) 
40) function verify_input_general( $input )
41) {
42)   if (filter_input_general($input) != $input)
43)     system_failure("Ihre Daten enthielten ungültige Zeichen!");
bernd input-filtering

bernd authored 16 years ago

44) }
45) 
46) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

47) 
bernd input-filtering

bernd authored 16 years ago

48) function filter_input_username( $input )
49) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

50)   if (ereg_replace("[^[:alnum:]\_\.\+\-]", "", $input ) != $input)
51)     system_failure("Ihre Daten enthielten ungültige Zeichen!");
bernd input-filtering

bernd authored 16 years ago

52) }
53) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

54) 
55) 
bernd check auf hostname

bernd authored 16 years ago

56) function filter_input_hostname( $input )
57) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

58)   $input = str_replace(array('Ä', 'Ö', 'Ü'), array('ä', 'ö', 'ü'), strtolower($input));
59)   if (ereg_replace("[^[:alnum:]äöü\.\-]", "", $input ) != $input)
60)     system_failure("Ihre Daten enthielten ungültige Zeichen!");
61)   return $input;
bernd check auf hostname

bernd authored 16 years ago

62) }
63) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

64) 
65) 
bernd Im Passwort dürfen auch kei...

bernd authored 16 years ago

66) function filter_quotes( $input )
67) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

68)   return ereg_replace('["\'`]', '', $input );
bernd Im Passwort dürfen auch kei...

bernd authored 16 years ago

69) }
70) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

71) 
72) 
bernd Diverse shell-kritische zei...

bernd authored 16 years ago

73) function filter_shell( $input )
74) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

75)   return ereg_replace('[^-[:alnum:]\_\.\+ßäöüÄÖÜ/%§=]', '', $input );
76) }
77) 
78) function verify_shell( $input )
79) {
80)   if (filter_shell($input) != $input)
81)     system_failure("Ihre Daten enthielten ungültige Zeichen!");
bernd Diverse shell-kritische zei...

bernd authored 16 years ago

82) }
bernd input-filtering

bernd authored 16 years ago

83) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

84) 
85) 
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

86) function check_path( $input )
87) {
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

88)   DEBUG("checking {$input} for valid path name");
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

89)   if ($input != filter_input_general($input))
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

90)   {
91)     DEBUG("HTML-Krams im Pfad");
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

92)     return False;
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

93)   }
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

94)   $components = explode("/", $input);
95)   foreach ($components AS $item)
96)   {
97)     if ($item == '..')
98)     {
bernd check auf hostname

bernd authored 16 years ago

99)       DEBUG("»..« im Pfad");
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

100)       return False;
101)     }
102)   }
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

103)   return (preg_match('/^[a-z0-9.@\/_-]*$/',$input) == 1);
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

104) }
105) 
106) 
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

107) function check_emailaddr( $input )
108) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

109)   return (preg_match("/^[a-z]+[a-z0-9]*[\.|\-|_]?[a-z0-9]+@([a-z0-9]*[\.|\-]?[a-z0-9]+){1,4}\.[a-z]{2,4}$/i", $input ) == 1);
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

110) }
111)