Can I take a LAN message sent to me and put it into a program to decrypt it?

天涯浪子 提交于 2019-12-24 07:45:04

问题


I've made a simple LAN messenger for talking to people on my network using this batch file:

@ echo off
:A
 cls
echo MESSENGER
set /p n=User:
set /p m=Message:
set /p z=Time:
msg /SERVER:%n% * /TIME:%z% "%m%"
Pause
Goto A

What I want to do is encrypt the message before it's sent with an algorithm and then decrypt the message on the recipient's end before the plaintext is displayed.

I've looked online and there doesn't seem to be much information on taking received messages and using them.


回答1:


A quick sol. and without going out of CMD... I would compress the message send it and then decompress it at the end point. At the eyes of an inexperienced user could look like a ciphered message. Actually is just adding few lines of code. Then your code would look like:

@ echo off
setlocal EnableDelayedExpansion

:A
cls
echo MESSENGER

set /p n=User:
set /p m=Message: & echo !m! > ~
set /p z=Time:

makecab ~ > nul
set /p m=<~._
del /f ~
del /f ~._

msg /SERVER:%n% * /TIME:%z% "%m%"

Pause
Goto A

Important: Currently redirecting the ~._ into m is not working properly.

Input:

This is a message

Output:

MSCF    \       ,               >              8O]z  ~ ╗+Å  CK╔╚,V óDà▄ÈÔÔ─¶T^.

At the client-side we can use expand to decompress the message. I don't know how the recepcion of the msg command works. But i am going to assume that it can be depicted as by the echo command. Therefore,

REM substitute echo by the reception command.
echo !rcv_msg! > ~
expand ~ msg.temp
type msg.temp
del /f msg.temp

It would more robust if we erase the MSCF characters which seems to be appended every time the compression is ran. And then append them at the beggining of the message before decompressing it.



来源:https://stackoverflow.com/questions/58066181/can-i-take-a-lan-message-sent-to-me-and-put-it-into-a-program-to-decrypt-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!