This function takes a tlsSession object and swaps the IP addresses, ports, connection ends and connection states. The triggered_commit are also swapped (though it is probably overkill, it is cleaner this way). It is useful for static analysis of a series of messages
(self)
| 565 | # Mirroring |
| 566 | |
| 567 | def mirror(self): |
| 568 | """ |
| 569 | This function takes a tlsSession object and swaps the IP addresses, |
| 570 | ports, connection ends and connection states. The triggered_commit are |
| 571 | also swapped (though it is probably overkill, it is cleaner this way). |
| 572 | |
| 573 | It is useful for static analysis of a series of messages from both the |
| 574 | client and the server. In such a situation, it should be used every |
| 575 | time the message being read comes from a different side than the one |
| 576 | read right before, as the reading state becomes the writing state, and |
| 577 | vice versa. For instance you could do:: |
| 578 | |
| 579 | client_hello = open('client_hello.raw').read() |
| 580 | <read other messages> |
| 581 | |
| 582 | m1 = TLS(client_hello) |
| 583 | m2 = TLS(server_hello, tls_session=m1.tls_session.mirror()) |
| 584 | m3 = TLS(server_cert, tls_session=m2.tls_session) |
| 585 | m4 = TLS(client_keyexchange, tls_session=m3.tls_session.mirror()) |
| 586 | """ |
| 587 | |
| 588 | self.ipdst, self.ipsrc = self.ipsrc, self.ipdst |
| 589 | self.dport, self.sport = self.sport, self.dport |
| 590 | |
| 591 | self.rcs, self.wcs = self.wcs, self.rcs |
| 592 | if self.rcs: |
| 593 | self.rcs.row = "read" |
| 594 | if self.wcs: |
| 595 | self.wcs.row = "write" |
| 596 | |
| 597 | self.prcs, self.pwcs = self.pwcs, self.prcs |
| 598 | if self.prcs: |
| 599 | self.prcs.row = "read" |
| 600 | if self.pwcs: |
| 601 | self.pwcs.row = "write" |
| 602 | |
| 603 | self.triggered_prcs_commit, self.triggered_pwcs_commit = \ |
| 604 | self.triggered_pwcs_commit, self.triggered_prcs_commit |
| 605 | |
| 606 | if self.connection_end == "client": |
| 607 | self.connection_end = "server" |
| 608 | elif self.connection_end == "server": |
| 609 | self.connection_end = "client" |
| 610 | |
| 611 | return self |
| 612 | |
| 613 | # Secrets management for SSLv3 to TLS 1.2 |
| 614 |
no outgoing calls
no test coverage detected