mirror of https://github.com/google/oss-fuzz.git
ntlm2-request: initial integration (#7800)
* ntlm2-request: initial integration
This commit is contained in:
parent
f00696989a
commit
54bd706197
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
FROM gcr.io/oss-fuzz-base/base-builder-python
|
||||
|
||||
RUN git clone https://github.com/dopstar/requests-ntlm2
|
||||
WORKDIR requests-ntlm2
|
||||
|
||||
COPY build.sh fuzz_*.py $SRC/
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash -eu
|
||||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Build and install project (using current CFLAGS, CXXFLAGS).
|
||||
pip3 install --upgrade pip
|
||||
pip3 install .
|
||||
|
||||
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
|
||||
compile_python_fuzzer $fuzzer
|
||||
done
|
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/python3
|
||||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import atheris
|
||||
import sys
|
||||
import socket
|
||||
import time
|
||||
from threading import Thread
|
||||
with atheris.instrument_imports():
|
||||
import requests
|
||||
from requests.exceptions import InvalidURL,ConnectionError
|
||||
from requests_ntlm2 import HttpNtlmAuth
|
||||
|
||||
class ServerThread(Thread):
|
||||
def __init__(self, fdp):
|
||||
self.fdp = fdp
|
||||
|
||||
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self.s.bind(("127.0.0.1", 8001))
|
||||
self.s.listen(1)
|
||||
|
||||
Thread.__init__(self)
|
||||
|
||||
def run(self):
|
||||
conn, addr = self.s.accept()
|
||||
conn.recv(self.fdp.ConsumeIntInRange(1024,2048))
|
||||
conn.send(self.fdp.ConsumeBytes(2048))
|
||||
time.sleep(0.005)
|
||||
conn.close()
|
||||
self.s.shutdown(1)
|
||||
self.s.close()
|
||||
time.sleep(0.01)
|
||||
|
||||
def TestInput(data):
|
||||
fdp = atheris.FuzzedDataProvider(data)
|
||||
|
||||
t1 = ServerThread(fdp)
|
||||
t1.start()
|
||||
|
||||
session = requests.Session()
|
||||
auth = HttpNtlmAuth(fdp.ConsumeString(50),fdp.ConsumeString(10))
|
||||
session.auth = HttpNtlmAuth(fdp.ConsumeString(50),fdp.ConsumeString(10))
|
||||
|
||||
try:
|
||||
requests.get('http://localhost:8001/%s'%fdp.ConsumeString(20),auth=auth)
|
||||
session.get('http://localhost:8001/%s'%fdp.ConsumeString(20))
|
||||
except (InvalidURL,ConnectionError) as e:
|
||||
pass
|
||||
|
||||
t1.join()
|
||||
|
||||
def main():
|
||||
atheris.Setup(sys.argv, TestInput, enable_python_coverage=True)
|
||||
atheris.instrument_all()
|
||||
atheris.Fuzz()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python3
|
||||
# Copyright 2022 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import atheris
|
||||
import sys
|
||||
with atheris.instrument_imports():
|
||||
import requests_ntlm2.core as core
|
||||
|
||||
def TestInput(data):
|
||||
fdp = atheris.FuzzedDataProvider(data)
|
||||
|
||||
core.get_ntlm_credentials(fdp.ConsumeString(50),fdp.ConsumeString(50))
|
||||
core.fix_target_info(fdp.ConsumeBytes(100))
|
||||
|
||||
def main():
|
||||
atheris.Setup(sys.argv, TestInput, enable_python_coverage=True)
|
||||
atheris.instrument_all()
|
||||
atheris.Fuzz()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,12 @@
|
|||
fuzzing_engines:
|
||||
- libfuzzer
|
||||
homepage: https://github.com/dopstar/requests-ntlm2
|
||||
language: python
|
||||
main_repo: https://github.com/dopstar/requests-ntlm2
|
||||
sanitizers:
|
||||
- address
|
||||
- undefined
|
||||
vendor_ccs:
|
||||
- david@adalogics.com
|
||||
- adam@adalogics.com
|
||||
- arthur.chan@adalogics.com
|
Loading…
Reference in New Issue