391c907dc9e64ff7cf138ea4a41bcfdeae4ae5c2
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) 
47) function filter_input_username( $input )
48) {
hanno Hatte die Kompatibilität ge...

hanno authored 16 years ago

49)   return ereg_replace("[^[:alnum:]\_\.\+\-]", "", $input );
50) }
51) 
52) function verify_input_username( $input )
53) {
54)   if (filter_input_username( $input ) != $input)
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

55)     system_failure("Ihre Daten enthielten ungültige Zeichen!");
bernd input-filtering

bernd authored 16 years ago

56) }
57) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

58) 
59) 
bernd check auf hostname

bernd authored 16 years ago

60) function filter_input_hostname( $input )
61) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

bernd authored 16 years ago

66) }
67) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

68) 
69) 
bernd Im Passwort dürfen auch kei...

bernd authored 16 years ago

70) function filter_quotes( $input )
71) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

bernd authored 16 years ago

73) }
74) 
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

75) 
76) 
bernd Diverse shell-kritische zei...

bernd authored 16 years ago

77) function filter_shell( $input )
78) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

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

bernd authored 16 years ago

86) }
bernd input-filtering

bernd authored 16 years ago

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

bernd authored 16 years ago

88) 
89) 
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

97)   }
bernd XSS/CSRF-Bugs behoben

bernd authored 16 years ago

98)   $components = explode("/", $input);
99)   foreach ($components AS $item)
100)   {
101)     if ($item == '..')
102)     {
bernd check auf hostname

bernd authored 16 years ago

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

bernd authored 16 years ago

104)       return False;
105)     }
106)   }
bernd Auch @ darf im Mailbox-Pfad...

bernd authored 16 years ago

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

bernd authored 16 years ago

108) }
109) 
110) 
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

111) function check_emailaddr( $input )
112) {
bernd Umfangreiche Code-Aufräumar...

bernd authored 16 years ago

113)   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

114) }
115)