Skip to content

Adding missing logic to enable TCP TLS server #62

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

Merged
merged 1 commit into from
Dec 23, 2021
Merged

Conversation

Mzack9999
Copy link
Member

@Mzack9999 Mzack9999 commented Dec 21, 2021

This PR adds missing logic to enable tcp tls server with custom responses:

rules.yaml

rules:
  - match: hey 
    response: |
              HTTP/1.0 200 OK
              Server: httpd/2.0
              x-frame-options: SAMEORIGIN
              x-xss-protection: 1; mode=block
              Date: Fri, 16 Apr 2021 14:30:32 GMT
              Content-Type: text/html
              Connection: close

              hello

server

$ sudo go run . -tcp -rules rules.yaml -listen 127.0.0.1:443 -tls

   _____ _                 __     __  __________________                                
  / ___/(_)___ ___  ____  / /__  / / / /_  __/_  __/ __ \________  ______   _____  _____
  \__ \/ / __ -__ \/ __ \/ / _ \/ /_/ / / /   / / / /_/ / ___/ _ \/ ___/ | / / _ \/ ___/
 ___/ / / / / / / / /_/ / /  __/ __  / / /   / / / ____(__  )  __/ /   | |/ /  __/ /    
/____/_/_/ /_/ /_/ .___/_/\___/_/ /_/ /_/   /_/ /_/   /____/\___/_/    |___/\___/_/     
                /_/                                                       - v0.0.4

                projectdiscovery.io

Use with caution. You are responsible for your actions
Developers assume no liability and are not responsible for any misuse or damage.
Serving TCP rule based tls server on tcp://127.0.0.1:443
hey / HTTP/1.1
Host: localhost
User-Agent: curl/7.77.0
Accept: */*


HTTP/1.0 200 OK
Server: httpd/2.0
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
Date: Fri, 16 Apr 2021 14:30:32 GMT
Content-Type: text/html
Connection: close

hello 

client

$ curl -X hey https://localhost/ -k -v
*   Trying ::1:443...
* connect to ::1 port 443 failed: Connection refused
*   Trying 127.0.0.1:443...
* Connected to localhost (127.0.0.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: O=Acme Co
*  start date: Dec 21 15:45:45 2021 GMT
*  expire date: Dec 21 15:45:45 2022 GMT
*  issuer: O=Acme Co
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> hey / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.77.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: httpd/2.0
< x-frame-options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< Date: Fri, 16 Apr 2021 14:30:32 GMT
< Content-Type: text/html
< Connection: close
< 
* TLSv1.2 (IN), TLS alert, close notify (256):
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, close notify (256):

@Mzack9999 Mzack9999 added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Dec 21, 2021
@Mzack9999 Mzack9999 self-assigned this Dec 21, 2021
@Mzack9999 Mzack9999 added the Status: Review Needed The issue has a PR attached to it which needs to be reviewed label Dec 21, 2021
@Mzack9999 Mzack9999 requested a review from ehsandeep December 21, 2021 15:46
@Mzack9999 Mzack9999 linked an issue Dec 21, 2021 that may be closed by this pull request
@ehsandeep ehsandeep added Status: Completed Nothing further to be done with this issue. Awaiting to be closed. and removed Status: Review Needed The issue has a PR attached to it which needs to be reviewed labels Dec 23, 2021
@ehsandeep ehsandeep merged commit 65f36a2 into dev Dec 23, 2021
@ehsandeep ehsandeep deleted the issue-52-tcp-tls branch December 23, 2021 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom responses using tls
2 participants