Add Anonymize IP plugin
This commit is contained in:
		
							
								
								
									
										59
									
								
								plugins/post_analysis/anonymize_ip.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								plugins/post_analysis/anonymize_ip.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| # | ||||
| # Copyright Grégory Soutadé 2022 | ||||
|  | ||||
| # This file is part of iwla | ||||
|  | ||||
| # iwla is free software: you can redistribute it and/or modify | ||||
| # it under the terms of the GNU General Public License as published by | ||||
| # the Free Software Foundation, either version 3 of the License, or | ||||
| # (at your option) any later version. | ||||
| # | ||||
| # iwla is distributed in the hope that it will be useful, | ||||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
| # | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with iwla.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
|  | ||||
| import hashlib | ||||
|  | ||||
| from iwla import IWLA | ||||
| from iplugin import IPlugin | ||||
|  | ||||
| """ | ||||
| Post analysis hook | ||||
|  | ||||
| Replace remote_addr by a SHA1 | ||||
|  | ||||
| Plugin requirements : | ||||
|     None | ||||
|  | ||||
| Conf values needed : | ||||
|     None | ||||
|  | ||||
| Output files : | ||||
|     None | ||||
|  | ||||
| Statistics creation : | ||||
|     None | ||||
|  | ||||
| Statistics update : | ||||
| valid_visitors: | ||||
|    remote_addr | ||||
|  | ||||
| Statistics deletion : | ||||
|     None | ||||
| """ | ||||
|  | ||||
| class IWLAPostAnalysisReverseDNS(IPlugin): | ||||
|          | ||||
|     def hook(self): | ||||
|         hits = self.iwla.getCurrentVisits() | ||||
|         for (k, hit) in hits.items(): | ||||
|             m = hashlib.sha1() | ||||
|             m.update(k.encode('utf-8')) | ||||
|             hit['remote_addr'] = m.hexdigest()[:16] | ||||
|  | ||||
		Reference in New Issue
	
	Block a user