INTRO
Windows and Linux have no similarity. one has its own pro and con. but when it comes to hackers. they use both of these operating systems. currently, I am using windows and Linux. basically, I am using Windows but I have Linux installed in another laptop that I use with SSH with Windows. But the biggest problem you will face in such a condition is not being able to share files from Windows to Linux or from Linux to Windows.
It is not just about the local system. you will also encounter this condition in many Windows CTFs where you will have to share some exploit scripts or some Powershell scripts to windows using windows. we are going to use a simple method through command prompt/Powershell.
Let me suggest you this HTB box “buff“. it hasn’t been retired yet. you can check this out. you can practice all the things here we are going to do in this article. but I am using this on my local system. But you will see that there is no difference.
ATTACK
You need to understand why file-sharing is not so easy in Linux and windows through USB and through internal networks. A year back, I wrote an article on how one can read Linux partition with Windows. it happens because of the format of the partition. Linux uses ext4 format which is not very famous and obviously not supported by windows drivers. but Windows uses NTFS format which is more very famous and supported by Linux to read and write into.
Now you can see that it is even difficult to read and write into Linux using Windows through USB or the same Hard disk. you can imagine how difficult it can be to share a file over a network. by the way, the easiest way to send files over a network is to host it first on an HTTP server. but we are going to use a different technique here. we are going to use the samba protocol to mount the file system of Linux into windows.
I am going to use a script “smbserver.py” to start the SMB server on Linux. it comes pre-installed in Kali-Linux. if you have any other Linux distribution. you will need to install impacket lib for python. to do so, type this command:
pip install impacket
Then you can google the script “smbserver.py”.
After that, You can run Smbserver on your Linux machine. type this command to start the server:
smbserver.py ShareName `pwd` -username lucky -password 1234 -smb2support
Screenshot:
The second argument “ShareName” is the share name and the third argument is to tell the server to start in such directory. in our case, we are starting the server in the current directory. -username and -password are the authentication flags. now the thing to notice is the last flag “-smb2support” which runs SMB version 2. sometimes, for some security purposes the windows won’t connect with SMBV1. so, it will be helpful at that time.
Now we need to connect to this SMBshare with Windows. so, to do that type this command:
net use z: \\192.168.43.183\ShareName /user:lucky 1234
Well, Windows says that command is successfully executed. so, we can change our drive z:.
Now we can list the content here with PowerShell cmdlet “Get-ChildItem“. and we can move into some other directories that our Linux has.
You can copy any item from Linux to Windows or from Windows to Linux. for example, I have the demo.txt in my Windows and I want to send it to my Linux. To do such a thing, type this command:
Copy-Item C:\Users\Public\demo.txt Z:\Desktop\
And that’s how you can share files between Linux and Windows with SMB protocol.
Thanks For Visiting.