def test_can_get_ip_from_request_META_REMOTE_ADDR(self): request = HttpRequest() request.META['REMOTE_ADDR'] = '192.131.111.133' ip = get_ip(request) self.assertEqual(ip, request.META['REMOTE_ADDR'])
def test_can_strip_string_ip_from_META_HTTP_X_FORWARDED_FOR(self): request = HttpRequest() request.META['HTTP_X_FORWARDED_FOR'] = ' 3.111.211.3 ' ip = get_ip(request) self.assertEqual(ip, '3.111.211.3')
def test_get_last_ip_from_META_HTTP_X_FORWARDED_FOR(self): request = HttpRequest() request.META['HTTP_X_FORWARDED_FOR'] = '192.131.111.133, 31.123.185.9 , 3.111.211.3' ip = get_ip(request) self.assertEqual(ip, '3.111.211.3')
def test_can_get_ip_from_request_META_HTTP_X_REAL_IP(self): request = HttpRequest() request.META['HTTP_X_REAL_IP'] = '31.123.185.9' ip = get_ip(request) self.assertEqual(ip, request.META['HTTP_X_REAL_IP'])
def test_get_ip_due_to_priority_2(self): request = HttpRequest() request.META['HTTP_X_REAL_IP'] = '99.1.15.9' request.META['REMOTE_ADDR'] = '192.131.111.133' ip = get_ip(request) self.assertEqual(ip, request.META['HTTP_X_REAL_IP'])
def new_comment(request, post_id): post = Post.objects.get(id=post_id) if request.user.is_authenticated: Comment.objects.create( post=post, content=request.POST['comment_content'], account=request.user, ip=get_ip(request) ) return redirect(reverse('board:comment_list', args=[post_id]))
def new_post(request, board_slug): board = Board.objects.get(slug=board_slug) if request.method == 'POST': post_form = PostForm(request.POST) attachment_form = AttachmentForm(request.POST, request.FILES) if post_form.is_valid() and attachment_form.is_valid() and request.user.is_authenticated: post = post_form.save(commit=False) post.board = board post.ip = get_ip(request) try: post.account = request.user except Post.DoesNotExist: post.account = None post.save() attachment = attachment_form.save(commit=False) attachment.post = post attachment.save() return redirect(board) else: post_form = PostForm() attachment_form = AttachmentForm() return render(request, 'new_post.html', {'board': board, 'post_form': post_form, 'attachment_form': attachment_form})
#Set the log level logger().log_level = logging.__dict__[options.log_level.upper()] from core.logger import logger formatter = logging.Formatter("%(asctime)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S") log = logger().setup_logger("MITMf", formatter) from core.netcreds import NetCreds if options.read_pcap: NetCreds().parse_pcap(options.read_pcap) #Check to see if we supplied a valid interface, pass the IP and MAC to the NameSpace object from core.utils import get_ip, get_mac, shutdown options.ip = get_ip(options.interface) options.mac = get_mac(options.interface) settings.Config.populate(options) log.debug("MITMf started: {}".format(sys.argv)) #Start Net-Creds print "[*] MITMf v{} - '{}'".format(mitmf_version, mitmf_codename) NetCreds().start(options.interface, options.ip) print "|" print "|_ Net-Creds v{} online".format(NetCreds.version) from core.proxyplugins import ProxyPlugins
def extract_data(self): logger.info("Extracting data from SAR probe") local_file = os.path.join(self.local_dir, "%s_sar.bin" % utils.get_ip(self.target)) utils.get_anywhere(self.target, self.probe_thread.remote_stdout, local_file) return local_file
def test_get_none_when_there_is_no_header(self): request = HttpRequest() ip = get_ip(request) self.assertIsNone(ip)