Created
September 23, 2019 14:52
-
-
Save ninjarobot/32421ef5976842d907fa8ada0ee34456 to your computer and use it in GitHub Desktop.
Using cracklib from F#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Runtime.InteropServices | |
[<DllImport("libcrack.so.2", CallingConvention=CallingConvention.Cdecl)>] | |
extern nativeint FascistCheck(string pw, string dictPath) | |
[<EntryPoint>] | |
let main argv = | |
while true do | |
Console.WriteLine "Enter a potential password:" | |
let input = Console.ReadLine () | |
try | |
let res = FascistCheck(input, "/var/cache/cracklib/cracklib_dict") | |
let s = Marshal.PtrToStringAnsi res | |
if String.IsNullOrEmpty s then | |
Console.WriteLine "Acceptable" | |
else | |
Console.WriteLine s | |
with | |
| :? DllNotFoundException -> | |
Console.Error.WriteLine "libcrack not installed." | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment