Skip to content

Instantly share code, notes, and snippets.

@Izder456
Created March 8, 2023 17:18
Show Gist options
  • Save Izder456/1cb06f85bc68d9a0da2d959ccb7fe5df to your computer and use it in GitHub Desktop.
Save Izder456/1cb06f85bc68d9a0da2d959ccb7fe5df to your computer and use it in GitHub Desktop.
getshells.lsp
(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