Created
March 8, 2023 17:18
-
-
Save Izder456/1cb06f85bc68d9a0da2d959ccb7fe5df to your computer and use it in GitHub Desktop.
getshells.lsp
This file contains 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
(defun inc (val) | |
(if val (1+ val) 1)) | |
(defun split-passwd (file) | |
(with-open-file (stream file :if-does-not-exist nil) | |
(when stream | |
(loop for line = (read-line stream nil) | |
while line | |
collect (subseq line (1+ (position #\: line :from-end t))))))) | |
(defun occurrences (lst) | |
(let ((table (make-hash-table :test #'equal))) | |
(loop for shell in lst | |
do (pushnew shell (getf table shell) :test #'equal)) | |
table)) | |
(defun main (&rest argv) | |
(time | |
(dolist (k (hash-table-keys (occurrences (split-passwd "passwd")))) | |
(format t "~a : ~a~%" k (getf (occurrences (split-passwd "passwd")) k))))) | |
(sb-ext:save-lisp-and-die "optimized" :executable t :toplevel #'main :compression 9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment