(self, req)
| 1587 | )) |
| 1588 | |
| 1589 | def make_reply(self, req): |
| 1590 | resp = req |
| 1591 | |
| 1592 | # Basic response |
| 1593 | resp = ( |
| 1594 | IP(src=req[IP].dst, dst=req[IP].src) / |
| 1595 | UDP(sport=req[UDP].dport, dport=req[UDP].sport) |
| 1596 | ) |
| 1597 | |
| 1598 | # Sort attributes for quick access |
| 1599 | attrs = { |
| 1600 | ( |
| 1601 | (x.vendor_id, x.vendor_type) |
| 1602 | if RadiusAttr_Vendor_Specific in x else |
| 1603 | x.type |
| 1604 | ): x |
| 1605 | for x in req.attributes |
| 1606 | } |
| 1607 | |
| 1608 | # Build Radius response |
| 1609 | rad = Radius(code=2, id=req[Radius].id) |
| 1610 | |
| 1611 | # Process various authentication methods |
| 1612 | try: |
| 1613 | if 2 in attrs: |
| 1614 | # PAP |
| 1615 | if not self.IDENTITIES: |
| 1616 | raise Scapy_Exception( |
| 1617 | "Missing IDENTITIES for User-Password auth ! Assuming OK." |
| 1618 | ) |
| 1619 | |
| 1620 | UserName = attrs[1].value |
| 1621 | KnownPassword = self.IDENTITIES.get(UserName.decode(), None) |
| 1622 | UserPassword = attrs[2].decrypt( |
| 1623 | req, |
| 1624 | self.secret, |
| 1625 | ) |
| 1626 | |
| 1627 | if KnownPassword is None: |
| 1628 | log_runtime.warning("Couldn't find user '%s'" % UserName.decode()) |
| 1629 | rad.code = 3 |
| 1630 | elif UserPassword != KnownPassword: |
| 1631 | log_runtime.warning( |
| 1632 | "Bad password for user '%s'" % UserName.decode() |
| 1633 | ) |
| 1634 | rad.code = 3 |
| 1635 | elif 79 in attrs: |
| 1636 | # EAP-Message is used |
| 1637 | raise Scapy_Exception( |
| 1638 | "EAP as a Radius auth method is not implemented !" |
| 1639 | ) |
| 1640 | elif (311, 25) in attrs: |
| 1641 | # MS-CHAP2 |
| 1642 | if not self.IDENTITIES_MSCHAPv2: |
| 1643 | raise Scapy_Exception("Missing IDENTITIES_MSCHAPv2 for MsChapV2 !") |
| 1644 | |
| 1645 | response = attrs[(311, 25)].value |
| 1646 | try: |
nothing calls this directly
no test coverage detected