Wrote ripe class
This commit is contained in:
		
						commit
						65a8744060
					
				
							
								
								
									
										6
									
								
								acasown.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								acasown.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| import ripe | ||||
| import censys | ||||
| import bong | ||||
| 
 | ||||
| r = ripe.Ripe() | ||||
| print(r.search("trenitalia")) | ||||
							
								
								
									
										0
									
								
								bong/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								bong/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										15
									
								
								censys/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								censys/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| import requests | ||||
| 
 | ||||
| class Censys: | ||||
| 	def __init__(self, login, secret): | ||||
| 		self.login = login | ||||
| 		self.gin = secret | ||||
| 
 | ||||
| 	def login(self): | ||||
| 		return True | ||||
| 
 | ||||
| 	def build_query(self, targets): | ||||
| 		return True | ||||
| 
 | ||||
| 	def search(self, query): | ||||
| 		return True | ||||
							
								
								
									
										22
									
								
								ripe/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								ripe/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import requests | ||||
| import logging | ||||
| 
 | ||||
| class Ripe: | ||||
|     def __init__(self): | ||||
|         self.ranges = [] | ||||
| 
 | ||||
|     def search(self, target): | ||||
|         r = requests.get("https://apps.db.ripe.net/db-web-ui/api/rest/fulltextsearch/select?facet=true&format=xml&hl=true&q=(" + target +")+AND+(object-type:inetnum)&start=0&wt=json", headers={"Accept": "application/json"}) | ||||
|         data = r.json() | ||||
|         total = data['result']['numFound'] | ||||
|         for i in range(0, total, 10): | ||||
|             r = requests.get("https://apps.db.ripe.net/db-web-ui/api/rest/fulltextsearch/select?facet=true&format=xml&hl=true&q=(" + target +")+AND+(object-type:inetnum)&start=" + str(i) + "&wt=json", headers={"Accept": "application/json"}) | ||||
|             self.parse(r.json()) | ||||
|         return self.ranges | ||||
| 
 | ||||
|     def parse(self, data): | ||||
|         for entry in data['result']['docs']: | ||||
|             for field in entry['doc']['strs']: | ||||
|                 if field['str']['name'] == 'inetnum': | ||||
|                     self.ranges.append({'start': field['str']['value'].split('-')[0].strip(), 'end': field['str']['value'].split('-')[1].strip()}) | ||||
| 
 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Giulio
						Giulio