Skip to content

Instantly share code, notes, and snippets.

@k2wanko
Created April 7, 2016 14:14
Show Gist options
  • Save k2wanko/6376006ce422f9a5286d8bcc801fcc11 to your computer and use it in GitHub Desktop.
Save k2wanko/6376006ce422f9a5286d8bcc801fcc11 to your computer and use it in GitHub Desktop.
xlsxba
import org.apache.poi.poifs.crypt.Decryptor
import org.apache.poi.poifs.crypt.EncryptionInfo
import org.apache.poi.poifs.filesystem.POIFSFileSystem
import java.io.FileInputStream
import java.math.BigInteger
fun main(args: Array<String>) {
val inputStream = FileInputStream("/path/to/file.xlsx")
val fileSystem = POIFSFileSystem(inputStream)
val info = EncryptionInfo(fileSystem)
val d = Decryptor.getInstance(info)
var i: BigInteger = 0L.big
while(!d.verifyPassword(i.to36)) {
i = i.add(BigInteger.ONE)
println("${i.to36} $i")
}
print("pass: ${i.to36}")
}
val Long.big: BigInteger
get() = BigInteger.valueOf(this)
val BigInteger.to36: String
get() = toString(36)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment