Regarding synopsis of commands - macos

I was playing with CHPASS command on my Mac OS X. I found the synopsis of CHPASS command on my bash shell and online is very different.
On my bash shell: chpass [-l location] [-u authname] [-s newshell] [user]
On google: chpass [-a list] [-p encpass] [-e expiretime] [-s newshell] [user]
chpass [-oly] [-a list] [-p encpass] [-e expiretime] [-s newshell]
[-d domain] [-h host] [user]
I didn't get why both synopsis are different. If I am right, do I need to update anything to get full synopsis? If yes, how do I do it?

There's no reason to think that the version of the chpass command you have on OS X is the same version of the command for which you found the synopsis online. You didn't provide any links so it's hard to know for sure, but it looks like you found online the documentation for the FreeBSD version version of the chpass command.
The man page for the OS X version of the command shows the same synopsis you found on your computer.
These are different implementations of the chpass command.

Related

Docker Run executing shell command can't access PATH environment variable

I'm using an official image from Microsoft which contains SQL tools used to interact with Microsoft SQL Servers. If I run the container interactively, I can run sqlcmd at the command line without any issue, because it is in the PATH variable:
$ docker run --rm -it -v $(pwd):/var/update/ -w /var/update mcr.microsoft.com/mssql-tools:latest
root#df20bd19b982:/var/update# sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 13.1.0007.0 Linux
Copyright (c) 2012 Microsoft. All rights reserved.
usage: sqlcmd [-U login id] [-P password]
[-S server or Dsn if -D is provided]
[-H hostname] [-E trusted connection]
[-N Encrypt Connection][-C Trust Server Certificate]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w screen width]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-c cmdend]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
[-u unicode output] [-r[0|1] msgs to stderr]
[-i inputfile] [-o outputfile]
[-k[1|2] remove[replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] print statistics[colon format]]
[-R use client regional setting]
[-K application intent]
[-M multisubnet failover]
[-b On error batch abort]
[-D Dsn flag, indicate -S is Dsn]
[-X[1] disable commands, startup script, environment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]
root#b33a916d4230:/var/update# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/mssql-tools/bin
root#b33a916d4230:/var/update#
sqlcmd is present in /opt/mssql-tools/bin/ folder which is part of the PATH env. variable.
but If I try to execute the sqlcmd command at the docker run... bash -c 'sqlcmd', it won't find it. I echoed PATH environment variable at the same command line and found that its path i.e /opt/mssql-tools/bin is already in the PATH.
$ docker run --rm -it -v $(pwd):/var/update/ -w /var/update mcr.microsoft.com/mssql-tools:latest bash -c "sqlcmd"
bash: sqlcmd: command not found
And to see the PATH env. variable, I did the following:
$docker run --rm -it -v $(pwd):/var/update/ -w /var/update mcr.microsoft.com/mssql-tools:latest bash -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Question 1: Why Path Variable is different in case we use bash -c 'commands'?
Question 2: If bash -c or sh -c creates a new shell, how to execute shell commands with the container's environment variables especially the PATH environment variable.
When you run an interactive shell as root, it runs the commands from /root/.bashrc, which (in this particular image) include
export PATH="$PATH:/opt/mssql-tools/bin"
A better Docker image would have that setting in the Dockerfile itself, which exports it to all users of the image. You can build an image like that yourself easily.
FROM mcr.microsoft.com/mssql-tools:latest
ENV PATH="$PATH:/opt/mssql-tools/bin"
(Also, the export is superfluous; the variable is already exported by the shell.)
If you don't want to mess with the image, try
docker run --rm -it -v $(pwd):/var/update/ -w /var/update \
mcr.microsoft.com/mssql-tools:latest \
bash -c 'PATH=$PATH:/opt/mssql/bin sqlcmd'

Why does this simple Hydra command not work despite the writeup specifying the exact same syntax?

So lately I have been trying to learn hydra from tryhackme, and tried to use this simple command
hydra -l molly -P /Users/root/Desktop/ctf/rockyou.txt 10.10.161.247 http-form-post "/:username=^USER^&password=^PASS^:F=incorrect" -V
But it does not work and shows
Syntax: hydra [[[-l LOGIN|-L FILE] [-p PASS|-P FILE]] | [-C FILE]] [-e nsr] [-o FILE] [-t TASKS]
[-M FILE [-T TASKS]] [-w TIME] [-W TIME] [-f] [-s PORT] [-x MIN:MAX:CHARSET] [-c TIME]
[ISOuvVd46] [service://server[:PORT][/OPT]]
What am i doing wrong?
I am using Hydra V9.0 on MacOS Mojave.
This is the writeup I am talking about.
You have to specify the directory for the login form.
Try this instead:
hydra -l molly -P [wordlist directory] [IP] http-form-post "login/:username=^USER^&password=^PASS^:F=incorrect" -V
This shall work.

Issue with lsof command

I have a service account executing below command on a solaris server
lsof -iTCP -n -P -F pcnfT -z$1
But I receive below error message as response
lsof: illegal option character: z
lsof 4.80 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abChlnNoOPRstUvV] [+|-c c] [+|-d s] [+|-D D] [+|-f[cfgGn]] [-F [f]] [-g [s]] [-i [i]] [-k k] [+|-L [l]] [-m m] [+|-M] [-o [o]] [-p s] [+|-r [t]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.
What can probably cause this issue? And what are potential solutions?
delete -z parameter as below;
lsof -iTCP -n -P -F pcnfT
-z [z] specifies how Solaris 10 and higher zone information is to be
handled.
Without a following argument - e.g., NO z - the option speci-
fies that zone names are to be listed in the ZONE output col-
umn.

Bash-Completion is broken after installation of Dotfiles

I've installed this dotfiles-repo on a newly installed OSX Yosemite Machine. I also ran its Scripts ~/.osx and brew.sh after installing homebrew. Everything works as expected, but not in the terminal.
After reboot each terminal starts with lots of errors:
-bash: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
-bash: complete: -D: invalid option
complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
Also, when i want to use bash completion, something like this happens:
mv Dropb-bash: ${prev,,}: bad substitution
I typed "mv Dropb" and pressed the Tab-key then. The other characters "-bash: $(prev..." occur then and restricts me to use the bash completion as it was possible before installing these dotfiles.
which part of the dotfiles should i change (or delete) to fix these issues?
As described in this blog post, OSX Yosemite comes with an dead old BASH-Version (3.2.57 right now) which does not support some newer stuff used in the dotfiles.
While the installation-script brew.sh, which is part of the dotfiles mentioned above, installs the current bash-version (4.3.33), it is not used right now by the terminal.
The following steps will register the bash installed via brew as the system-wide-bash:
sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
chsh -s /usr/local/bin/bash

What is the growlnotify -c option?

If growlnotify -h:
Usage: growlnotify [-hsvuwc] [-i ext] [-I filepath] [--image filepath]
[-a appname] [-p priority] [-H host] [-P password]
[-n name] [-A method] [--html] [-m message] [-t] [--url url]
[title]
But the meaning of c in [-hsvuwc] is not described. What could it be?
Update:
the official man page installed with the program has no description of a c option. Several online man pages I found has neither.
From the man page:
-c,--crypt Encrypt UDP notifications. By default, UDP notifications are sent unencrypted.
-c,--crypt Encrypt UDP notifications.
per growlnotify -h on my install.

Resources