Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this redemption-validator-sock #120

Open
wscgogogo opened this issue Dec 25, 2020 · 11 comments
Open

How to use this redemption-validator-sock #120

wscgogogo opened this issue Dec 25, 2020 · 11 comments
Labels

Comments

@wscgogogo
Copy link

wscgogogo commented Dec 25, 2020

Hi:
I would like to know that I want the user to go through my verification program when copying in or out files or contents. If the verification passes, it is allowed to copy in and out. If the verification fails, it is not allowed to copy in and out.The following in the configuration file seems to achieve this function.If so, how can I implement this socket?

[file_verification]

#_hidden
socket_path = /var/run/redemption/redemption-validator-sock

Enable use of ICAP service for file verification on upload.

value: 0 or 1

#_hidden
#enable_up = 0

@jonathanpoelen
Copy link
Contributor

You have to write the validator yourself.

The format of the packets are described in https://github.com/wallix/redemption/blob/future/src/mod/file_validator_service.hpp

A fake validator for tests based on filenames: https://github.com/wallix/redemption/blob/future/tools/icap_validator/fake_validator.py

Note: id/file_id/local_file_id is a value incremented by the proxy and the exchanges may contain an id which no longer exists when messages cross (ex: the proxy sends Eof while the validator sends Result)

@wscgogogo
Copy link
Author

thank you very much,I have tried to verify the files upload and download without any problems,but I have another problem,can I varify the text copied from clipboard.when I use this validator it dosen't work.

@jonathanpoelen
Copy link
Contributor

You need clipboard_text_up=1.

@wscgogogo
Copy link
Author

I have already turn it on.I use function like this
#####fake_validator.py
def process_data(message, client_socket, data):
file_id, = struct.unpack_from(">I", message)
msg_data = message[4:]
print(msg_data)
if b'test' in msg_data:
print('find invalid data')
send_response_message(client_socket, file_id, REJECTED, b'test')
#####where to call
...
if type == 0x01: # File Data Flag
print('parse_message: file data')
process_data(message, client_socket, data)
...
#####log like this.I return 0x01 successfully but I can still copy the illegal data
parse_message: new data
1 8
session 3: type=1 len=8
parse_message: file data
b'test'
find invalid data
send: file_id=1 content=b'test'
b'\x05\x00\x00\x00\x10\x01\x00\x00\x00\x01\x00\x00\x00\x07test'
3 4
session 3: type=3 len=4
parse_message: end of file

@jonathanpoelen
Copy link
Contributor

This is a bug

@wscgogogo
Copy link
Author

fine,wait for the good news

@wscgogogo
Copy link
Author

This is a bug
thank you very much.I have got your update and the function is worked,but I found another problem. When I use a validated file passed byfake_validator.py , I find that my file is broken.excel file hint me to fix it.exe file is broken.txt file looks fine.Verifier theory doesn't modify a copy of a file, right?

@jonathanpoelen
Copy link
Contributor

The validation does not modify the data, but when a file is refused N null characters are sent (limitation of the RDP protocol). If this happens with an authorized file, could check the pasted file to be the same size as the original file (servers and client may send more data than the file contains, it may not be properly ignored) or determine how many bytes the files diverge from ?

@wscgogogo
Copy link
Author

I compared two file before transmission and after transmission.transfered file is bigger.The file is truncated and fill with null character.Another question,when should I return validatied result.I tried in begining,in progress and the end. when I return pass or reject at 0x07 package,file and message will be transfered correctory,but in this condition I can only validate filename but not file content and message body.When I pending request in 0x07 and 0x01,only return pass or reject at 0x03,I can successful allow or reject the file and message transmission.When I do like this,I find the problem before file after transmission is broken.this is the file compare result
image

@wscgogogo
Copy link
Author

hello.Do you still

@jonathanpoelen
Copy link
Contributor

I forgot you... :)

I have the impression that you send a response twice: accepted then rejected. If so, you should not do it, there should only be one response per id.

If not, are there any interesting messages in the proxy logs? And with [debug] mod_rdp=0x4000000 in rdpproxy.ini ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants