├── AUTHORS ├── CHANGELOG.md ├── LICENSE ├── README.md ├── automactc.py ├── deploy.sh ├── licenses ├── ccl_bplist-LICENSE.txt ├── codesign-LICENSE.txt ├── dateutil-LICENSE.txt ├── macMRU-LICENSE.txt ├── mac_alias-LICENSE.txt ├── osxcollector-LICENSE.md.txt ├── xattr-LICENSE.txt └── yelp-dataset-examples-LICENSE.txt └── modules ├── .gitignore ├── __init__.py ├── common ├── .gitignore ├── Crypto │ ├── Cipher │ │ ├── AES.py │ │ ├── AES.pyi │ │ ├── __init__.py │ │ ├── __init__.pyi │ │ ├── _cpu_features.py │ │ ├── _cpu_features.pyi │ │ ├── _file_system.py │ │ ├── _file_system.pyi │ │ ├── _mode_cbc.py │ │ ├── _mode_cbc.pyi │ │ ├── _raw_aes.so │ │ ├── _raw_aes_arm.so │ │ ├── _raw_aesni.so │ │ ├── _raw_api.py │ │ ├── _raw_api.pyi │ │ ├── _raw_cbc.so │ │ ├── _raw_cbc_ACTUAL.so │ │ ├── _raw_cbc_arm.so │ │ ├── cffi │ │ │ ├── __init__.py │ │ │ ├── _cffi_errors.h │ │ │ ├── _cffi_include.h │ │ │ ├── _embedding.h │ │ │ ├── api.py │ │ │ ├── backend_ctypes.py │ │ │ ├── cffi_opcode.py │ │ │ ├── commontypes.py │ │ │ ├── cparser.py │ │ │ ├── error.py │ │ │ ├── ffiplatform.py │ │ │ ├── lock.py │ │ │ ├── model.py │ │ │ ├── parse_c_type.h │ │ │ ├── pkgconfig.py │ │ │ ├── recompiler.py │ │ │ ├── setuptools_ext.py │ │ │ ├── vengine_cpy.py │ │ │ ├── vengine_gen.py │ │ │ └── verifier.py │ │ ├── py3compat.py │ │ └── py3compat.pyi │ ├── Util │ │ ├── __init__.py │ │ ├── _cpuid_c.so │ │ └── _cpuid_c_arm.so │ ├── __init__.py │ └── __init__.pyi ├── __init__.py ├── ccl_bplist.py ├── codesign.py ├── dateutil │ ├── __init__.py │ ├── _common.py │ ├── parser │ │ ├── __init__.py │ │ ├── _parser.py │ │ └── isoparser.py │ ├── relativedelta.py │ ├── tz │ │ ├── __init__.py │ │ ├── _common.py │ │ ├── _factories.py │ │ ├── tz.py │ │ └── win.py │ └── tzwin.py ├── dep │ ├── __init__.py │ ├── _cffi_backend.cpython-37m-darwin.so │ ├── _cffi_backend.cpython-38-darwin.so │ ├── _cffi_backend.cpython-39-darwin.so │ ├── bin │ │ └── xattr │ ├── cffi-1.14.0.dist-info │ │ ├── INSTALLER │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── RECORD │ │ ├── WHEEL │ │ ├── entry_points.txt │ │ └── top_level.txt │ ├── cffi37 │ │ ├── __init__.py │ │ ├── _cffi_errors.h │ │ ├── _cffi_include.h │ │ ├── _embedding.h │ │ ├── api.py │ │ ├── backend_ctypes.py │ │ ├── cffi_opcode.py │ │ ├── commontypes.py │ │ ├── cparser.py │ │ ├── error.py │ │ ├── ffiplatform.py │ │ ├── lock.py │ │ ├── model.py │ │ ├── parse_c_type.h │ │ ├── pkgconfig.py │ │ ├── recompiler.py │ │ ├── setuptools_ext.py │ │ ├── vengine_cpy.py │ │ ├── vengine_gen.py │ │ └── verifier.py │ ├── cffi38 │ │ ├── __init__.py │ │ ├── _cffi_errors.h │ │ ├── _cffi_include.h │ │ ├── _embedding.h │ │ ├── api.py │ │ ├── backend_ctypes.py │ │ ├── cffi_opcode.py │ │ ├── commontypes.py │ │ ├── cparser.py │ │ ├── error.py │ │ ├── ffiplatform.py │ │ ├── lock.py │ │ ├── model.py │ │ ├── parse_c_type.h │ │ ├── pkgconfig.py │ │ ├── recompiler.py │ │ ├── setuptools_ext.py │ │ ├── vengine_cpy.py │ │ ├── vengine_gen.py │ │ └── verifier.py │ ├── cffi39 │ │ ├── __init__.py │ │ ├── _cffi_errors.h │ │ ├── _cffi_include.h │ │ ├── _embedding.h │ │ ├── api.py │ │ ├── backend_ctypes.py │ │ ├── cffi_opcode.py │ │ ├── commontypes.py │ │ ├── cparser.py │ │ ├── error.py │ │ ├── ffiplatform.py │ │ ├── lock.py │ │ ├── model.py │ │ ├── parse_c_type.h │ │ ├── pkgconfig.py │ │ ├── recompiler.py │ │ ├── setuptools_ext.py │ │ ├── vengine_cpy.py │ │ ├── vengine_gen.py │ │ └── verifier.py │ ├── pycparser-2.20.dist-info │ │ ├── INSTALLER │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── RECORD │ │ ├── WHEEL │ │ └── top_level.txt │ ├── pycparser │ │ ├── __init__.py │ │ ├── _ast_gen.py │ │ ├── _build_tables.py │ │ ├── _c_ast.cfg │ │ ├── ast_transforms.py │ │ ├── c_ast.py │ │ ├── c_generator.py │ │ ├── c_lexer.py │ │ ├── c_parser.py │ │ ├── lextab.py │ │ ├── ply │ │ │ ├── __init__.py │ │ │ ├── cpp.py │ │ │ ├── ctokens.py │ │ │ ├── lex.py │ │ │ ├── yacc.py │ │ │ └── ygen.py │ │ ├── plyparser.py │ │ └── yacctab.py │ ├── six-1.15.0.dist-info │ │ ├── INSTALLER │ │ ├── LICENSE │ │ ├── METADATA │ │ ├── RECORD │ │ ├── WHEEL │ │ └── top_level.txt │ ├── six.py │ ├── xattr-0.9.7.dist-info │ │ ├── INSTALLER │ │ ├── LICENSE.txt │ │ ├── METADATA │ │ ├── RECORD │ │ ├── WHEEL │ │ ├── entry_points.txt │ │ └── top_level.txt │ └── xattr │ │ ├── __init__.py │ │ ├── _lib.abi3.so │ │ ├── compat.py │ │ ├── lib.py │ │ ├── lib_build.c │ │ ├── lib_build.h │ │ ├── lib_build.py │ │ ├── pyxattr_compat.py │ │ └── tool.py ├── functions.py ├── json_to_csv.py ├── mac_alias │ ├── .gitignore │ ├── __init__.py │ ├── alias.py │ ├── bookmark.py │ ├── osx.py │ └── utils.py ├── xattr │ ├── __init__.py │ ├── compat.py │ ├── lib.py │ ├── lib_build.c │ ├── lib_build.h │ ├── lib_build.py │ ├── pyxattr_compat.py │ ├── tests │ │ ├── __init__.py │ │ └── test_xattr.py │ └── tool.py └── xmltodict │ ├── __init__.py │ └── xmltodict.py ├── mod_asl.py ├── mod_auditlog.py ├── mod_autoruns.py ├── mod_bash.py ├── mod_chrome.py ├── mod_cookies.py ├── mod_coreanalytics.py ├── mod_dirlist.py ├── mod_firefox.py ├── mod_installhistory.py ├── mod_live_1_pslist.py ├── mod_live_2_lsof.py ├── mod_live_3_netstat.py ├── mod_live_4_unifiedlogs.py ├── mod_mru.py ├── mod_netconfig.py ├── mod_quarantines.py ├── mod_quicklook.py ├── mod_safari.py ├── mod_spotlight.py ├── mod_ssh.py ├── mod_syslog.py ├── mod_systeminfo.py ├── mod_terminalstate.py ├── mod_users.py └── mod_utmpx.py /AUTHORS: -------------------------------------------------------------------------------- 1 | Jai Musunuri 2 | jai.musunuri@gmail.com, jai.musunuri@crowdstrike.com 3 | 4 | Anthony Martinez 5 | martinez.anthonyb@gmail.com, anthony.martinez@crowdstrike.com 6 | 7 | Wayland Morgan 8 | wayland.morgan@notx11.us, wayland.morgan@crowdstrike.com 9 | 10 | Megan Andersen 11 | mego888@gmail.com, megan.andersen@crowdstrike.com 12 | 13 | Eric John 14 | eric@intramortem.com 15 | 16 | Kshitij Kumar 17 | kshitijkumar14@gmail.com -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | Copyright (c) 2020, CrowdStrike, Inc. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | folderName="automactc" 2 | prefix="automactc-output" 3 | fmt="json" 4 | 5 | pypath="/usr/bin/python" 6 | 7 | tar xf $folderName.tar.gz 8 | cd $folderName 9 | 10 | sudo $pypath automactc.py --rtr --prefix $prefix -fmt $fmt -x quicklook coreanalytics safari 11 | 12 | mv $prefix*.tar.gz ../. 13 | cd ../ 14 | rm -rf $folderName 15 | rm $folderName.tar.gz 16 | rm deploy.sh 17 | -------------------------------------------------------------------------------- /licenses/ccl_bplist-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2016, CCL Forensics 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the CCL Forensics nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL CCL FORENSICS BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /licenses/dateutil-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2017- Paul Ganssle 2 | Copyright 2017- dateutil contributors (see AUTHORS file) 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | The above license applies to all contributions after 2017-12-01, as well as 17 | all contributions that have been re-licensed (see AUTHORS file for the list of 18 | contributors who have re-licensed their code). 19 | -------------------------------------------------------------------------------- 20 | dateutil - Extensions to the standard Python datetime module. 21 | 22 | Copyright (c) 2003-2011 - Gustavo Niemeyer 23 | Copyright (c) 2012-2014 - Tomi Pieviläinen 24 | Copyright (c) 2014-2016 - Yaron de Leeuw 25 | Copyright (c) 2015- - Paul Ganssle 26 | Copyright (c) 2015- - dateutil contributors (see AUTHORS file) 27 | 28 | All rights reserved. 29 | 30 | Redistribution and use in source and binary forms, with or without 31 | modification, are permitted provided that the following conditions are met: 32 | 33 | * Redistributions of source code must retain the above copyright notice, 34 | this list of conditions and the following disclaimer. 35 | * Redistributions in binary form must reproduce the above copyright notice, 36 | this list of conditions and the following disclaimer in the documentation 37 | and/or other materials provided with the distribution. 38 | * Neither the name of the copyright holder nor the names of its 39 | contributors may be used to endorse or promote products derived from 40 | this software without specific prior written permission. 41 | 42 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 45 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 46 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 47 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 48 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 49 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 50 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 51 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 52 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 | 54 | The above BSD License Applies to all code, even that also covered by Apache 2.0. -------------------------------------------------------------------------------- /licenses/macMRU-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Station X Labs, LLC 2 | All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | * Redistributions of source code must retain the above copyright 6 | notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | * Neither the name of the Station X Labs, LLC nor the 11 | names of its contributors may be used to endorse or promote products 12 | derived from this software without specific prior written permission. 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL STATION X LABS, LLC BE LIABLE FOR ANY 17 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /licenses/mac_alias-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Alastair Houghton 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /licenses/osxcollector-LICENSE.md.txt: -------------------------------------------------------------------------------- 1 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 2 | 3 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 4 | 5 | You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. 6 | -------------------------------------------------------------------------------- /licenses/xattr-LICENSE.txt: -------------------------------------------------------------------------------- 1 | This is the MIT license. This software may also be distributed under the same terms as Python (the PSF license). 2 | 3 | Copyright (c) 2004 Bob Ippolito. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /licenses/yelp-dataset-examples-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011 Yelp 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /modules/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.pyc 3 | .DS_Store 4 | __pycache__ 5 | .idea 6 | *.sublime-project 7 | *.sublime-workspace 8 | ._* 9 | *.tar.gz 10 | *.tar 11 | *.csv 12 | *.json -------------------------------------------------------------------------------- /modules/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | -------------------------------------------------------------------------------- /modules/common/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.pyc 3 | .DS_Store 4 | __pycache__ 5 | .idea 6 | *.sublime-project 7 | *.sublime-workspace 8 | ._* 9 | *.tar.gz 10 | *.tar 11 | *.csv 12 | *.json -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/AES.pyi: -------------------------------------------------------------------------------- 1 | from typing import Union, Tuple, Optional, Dict 2 | 3 | from Crypto.Cipher._mode_ecb import EcbMode 4 | from Crypto.Cipher._mode_cbc import CbcMode 5 | from Crypto.Cipher._mode_cfb import CfbMode 6 | from Crypto.Cipher._mode_ofb import OfbMode 7 | from Crypto.Cipher._mode_ctr import CtrMode 8 | from Crypto.Cipher._mode_openpgp import OpenPgpMode 9 | from Crypto.Cipher._mode_ccm import CcmMode 10 | from Crypto.Cipher._mode_eax import EaxMode 11 | from Crypto.Cipher._mode_gcm import GcmMode 12 | from Crypto.Cipher._mode_siv import SivMode 13 | from Crypto.Cipher._mode_ocb import OcbMode 14 | 15 | AESMode = int 16 | 17 | MODE_ECB: AESMode 18 | MODE_CBC: AESMode 19 | MODE_CFB: AESMode 20 | MODE_OFB: AESMode 21 | MODE_CTR: AESMode 22 | MODE_OPENPGP: AESMode 23 | MODE_CCM: AESMode 24 | MODE_EAX: AESMode 25 | MODE_GCM: AESMode 26 | MODE_SIV: AESMode 27 | MODE_OCB: AESMode 28 | 29 | Buffer = Union[bytes, bytearray, memoryview] 30 | 31 | def new(key: Buffer, 32 | mode: AESMode, 33 | iv : Buffer = ..., 34 | IV : Buffer = ..., 35 | nonce : Buffer = ..., 36 | segment_size : int = ..., 37 | mac_len : int = ..., 38 | assoc_len : int = ..., 39 | initial_value : Union[int, Buffer] = ..., 40 | counter : Dict = ..., 41 | use_aesni : bool = ...) -> \ 42 | Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, 43 | OpenPgpMode, CcmMode, EaxMode, GcmMode, 44 | SivMode, OcbMode]: ... 45 | 46 | block_size: int 47 | key_size: Tuple[int, int, int] 48 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # A block cipher is instantiated as a combination of: 3 | # 1. A base cipher (such as AES) 4 | # 2. A mode of operation (such as CBC) 5 | # 6 | # Both items are implemented as C modules. 7 | # 8 | # The API of #1 is (replace "AES" with the name of the actual cipher): 9 | # - AES_start_operaion(key) --> base_cipher_state 10 | # - AES_encrypt(base_cipher_state, in, out, length) 11 | # - AES_decrypt(base_cipher_state, in, out, length) 12 | # - AES_stop_operation(base_cipher_state) 13 | # 14 | # Where base_cipher_state is AES_State, a struct with BlockBase (set of 15 | # pointers to encrypt/decrypt/stop) followed by cipher-specific data. 16 | # 17 | # The API of #2 is (replace "CBC" with the name of the actual mode): 18 | # - CBC_start_operation(base_cipher_state) --> mode_state 19 | # - CBC_encrypt(mode_state, in, out, length) 20 | # - CBC_decrypt(mode_state, in, out, length) 21 | # - CBC_stop_operation(mode_state) 22 | # 23 | # where mode_state is a a pointer to base_cipher_state plus mode-specific data. 24 | 25 | import os 26 | 27 | from ._mode_cbc import _create_cbc_cipher 28 | 29 | _modes = { 2:_create_cbc_cipher, 30 | } 31 | 32 | _extra_modes = { 33 | } 34 | 35 | def _create_cipher(factory, key, mode, *args, **kwargs): 36 | 37 | kwargs["key"] = key 38 | 39 | modes = dict(_modes) 40 | if kwargs.pop("add_aes_modes", False): 41 | modes.update(_extra_modes) 42 | if not mode in modes: 43 | raise ValueError("Mode not supported") 44 | 45 | if args: 46 | if mode in (8, 9, 10, 11, 12): 47 | if len(args) > 1: 48 | raise TypeError("Too many arguments for this mode") 49 | kwargs["nonce"] = args[0] 50 | elif mode in (2, 3, 5, 7): 51 | if len(args) > 1: 52 | raise TypeError("Too many arguments for this mode") 53 | kwargs["IV"] = args[0] 54 | elif mode == 6: 55 | if len(args) > 0: 56 | raise TypeError("Too many arguments for this mode") 57 | elif mode == 1: 58 | raise TypeError("IV is not meaningful for the ECB mode") 59 | 60 | return modes[mode](factory, **kwargs) 61 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/__init__.pyi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Cipher/__init__.pyi -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_cpu_features.py: -------------------------------------------------------------------------------- 1 | # =================================================================== 2 | # 3 | # Copyright (c) 2018, Helder Eijs 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in 14 | # the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 27 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | # POSSIBILITY OF SUCH DAMAGE. 29 | # =================================================================== 30 | 31 | from ._raw_api import load_pycryptodome_raw_lib 32 | 33 | 34 | try: 35 | _raw_cpuid_lib = load_pycryptodome_raw_lib("Crypto.Util._cpuid_c", 36 | """ 37 | int have_aes_ni(void); 38 | int have_clmul(void); 39 | """) 40 | except Exception: 41 | _raw_cpuid_lib = load_pycryptodome_raw_lib("Crypto.Util._cpuid_c_arm", 42 | """ 43 | int have_aes_ni(void); 44 | int have_clmul(void); 45 | """) 46 | 47 | 48 | def have_aes_ni(): 49 | return _raw_cpuid_lib.have_aes_ni() 50 | 51 | 52 | def have_clmul(): 53 | return _raw_cpuid_lib.have_clmul() 54 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_cpu_features.pyi: -------------------------------------------------------------------------------- 1 | def have_aes_ni() -> int: ... 2 | def have_clmul() -> int: ... 3 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_file_system.py: -------------------------------------------------------------------------------- 1 | # =================================================================== 2 | # 3 | # Copyright (c) 2016, Legrandin 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 10 | # 1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # 2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in 14 | # the documentation and/or other materials provided with the 15 | # distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 27 | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | # POSSIBILITY OF SUCH DAMAGE. 29 | # =================================================================== 30 | 31 | import os 32 | 33 | 34 | def pycryptodome_filename(dir_comps, filename): 35 | """Return the complete file name for the module 36 | 37 | dir_comps : list of string 38 | The list of directory names in the PyCryptodome package. 39 | The first element must be "Crypto". 40 | 41 | filename : string 42 | The filename (inclusing extension) in the target directory. 43 | """ 44 | 45 | if dir_comps[0] != "Crypto": 46 | raise ValueError("Only available for modules under 'Crypto'") 47 | 48 | dir_comps = list(dir_comps[1:]) + [filename] 49 | 50 | util_lib, _ = os.path.split(os.path.abspath(__file__)) 51 | root_lib = os.path.join(util_lib, "..") 52 | 53 | return os.path.join(root_lib, *dir_comps) 54 | 55 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_file_system.pyi: -------------------------------------------------------------------------------- 1 | from typing import List 2 | 3 | 4 | def pycryptodome_filename(dir_comps: List[str], filename: str) -> str: ... -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_mode_cbc.pyi: -------------------------------------------------------------------------------- 1 | from typing import Union, overload 2 | 3 | from Crypto.Util._raw_api import SmartPointer 4 | 5 | Buffer = Union[bytes, bytearray, memoryview] 6 | 7 | __all__ = ['CbcMode'] 8 | 9 | class CbcMode(object): 10 | block_size: int 11 | iv: Buffer 12 | IV: Buffer 13 | 14 | def __init__(self, 15 | block_cipher: SmartPointer, 16 | iv: Buffer) -> None: ... 17 | @overload 18 | def encrypt(self, plaintext: Buffer) -> bytes: ... 19 | @overload 20 | def encrypt(self, plaintext: Buffer, output: Union[bytearray, memoryview]) -> None: ... 21 | @overload 22 | def decrypt(self, plaintext: Buffer) -> bytes: ... 23 | @overload 24 | def decrypt(self, plaintext: Buffer, output: Union[bytearray, memoryview]) -> None: ... 25 | 26 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_raw_aes.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Cipher/_raw_aes.so -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_raw_aes_arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Cipher/_raw_aes_arm.so -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_raw_aesni.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Cipher/_raw_aesni.so -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_raw_api.pyi: -------------------------------------------------------------------------------- 1 | from typing import Any, Optional, Union 2 | 3 | def load_lib(name: str, cdecl: str) -> Any : ... 4 | def c_ulong(x: int ) -> Any : ... 5 | def c_ulonglong(x: int ) -> Any : ... 6 | def c_size_t(x: int) -> Any : ... 7 | def create_string_buffer(init_or_size: Union[bytes,int], size: Optional[int]) -> Any : ... 8 | def get_c_string(c_string: Any) -> bytes : ... 9 | def get_raw_buffer(buf: Any) -> bytes : ... 10 | def c_uint8_ptr(data: Union[bytes, memoryview, bytearray]) -> Any : ... 11 | 12 | class VoidPointer(object): 13 | def get(self) -> Any : ... 14 | def address_of(self) -> Any : ... 15 | 16 | class SmartPointer(object): 17 | def __init__(self, raw_pointer: Any, destructor: Any) -> None : ... 18 | def get(self) -> Any : ... 19 | def release(self) -> Any : ... 20 | 21 | backend : str 22 | null_pointer : Any 23 | ffi: Any 24 | 25 | def load_pycryptodome_raw_lib(name: str, cdecl: str) -> Any : ... 26 | def is_buffer(x: Any) -> bool : ... 27 | def is_writeable_buffer(x: Any) -> bool : ... 28 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_raw_cbc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Cipher/_raw_cbc.so -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_raw_cbc_ACTUAL.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Cipher/_raw_cbc_ACTUAL.so -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/_raw_cbc_arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Cipher/_raw_cbc_arm.so -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/cffi/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['FFI', 'VerificationError', 'VerificationMissing', 'CDefError', 2 | 'FFIError'] 3 | 4 | from .api import FFI 5 | from .error import CDefError, FFIError, VerificationError, VerificationMissing 6 | from .error import PkgConfigError 7 | 8 | __version__ = "1.14.5" 9 | __version_info__ = (1, 14, 5) 10 | 11 | # The verifier module file names are based on the CRC32 of a string that 12 | # contains the following version number. It may be older than __version__ 13 | # if nothing is clearly incompatible. 14 | __version_verifier_modules__ = "0.8.6" 15 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/cffi/_cffi_errors.h: -------------------------------------------------------------------------------- 1 | #ifndef CFFI_MESSAGEBOX 2 | # ifdef _MSC_VER 3 | # define CFFI_MESSAGEBOX 1 4 | # else 5 | # define CFFI_MESSAGEBOX 0 6 | # endif 7 | #endif 8 | 9 | 10 | #if CFFI_MESSAGEBOX 11 | /* Windows only: logic to take the Python-CFFI embedding logic 12 | initialization errors and display them in a background thread 13 | with MessageBox. The idea is that if the whole program closes 14 | as a result of this problem, then likely it is already a console 15 | program and you can read the stderr output in the console too. 16 | If it is not a console program, then it will likely show its own 17 | dialog to complain, or generally not abruptly close, and for this 18 | case the background thread should stay alive. 19 | */ 20 | static void *volatile _cffi_bootstrap_text; 21 | 22 | static PyObject *_cffi_start_error_capture(void) 23 | { 24 | PyObject *result = NULL; 25 | PyObject *x, *m, *bi; 26 | 27 | if (InterlockedCompareExchangePointer(&_cffi_bootstrap_text, 28 | (void *)1, NULL) != NULL) 29 | return (PyObject *)1; 30 | 31 | m = PyImport_AddModule("_cffi_error_capture"); 32 | if (m == NULL) 33 | goto error; 34 | 35 | result = PyModule_GetDict(m); 36 | if (result == NULL) 37 | goto error; 38 | 39 | #if PY_MAJOR_VERSION >= 3 40 | bi = PyImport_ImportModule("builtins"); 41 | #else 42 | bi = PyImport_ImportModule("__builtin__"); 43 | #endif 44 | if (bi == NULL) 45 | goto error; 46 | PyDict_SetItemString(result, "__builtins__", bi); 47 | Py_DECREF(bi); 48 | 49 | x = PyRun_String( 50 | "import sys\n" 51 | "class FileLike:\n" 52 | " def write(self, x):\n" 53 | " try:\n" 54 | " of.write(x)\n" 55 | " except: pass\n" 56 | " self.buf += x\n" 57 | "fl = FileLike()\n" 58 | "fl.buf = ''\n" 59 | "of = sys.stderr\n" 60 | "sys.stderr = fl\n" 61 | "def done():\n" 62 | " sys.stderr = of\n" 63 | " return fl.buf\n", /* make sure the returned value stays alive */ 64 | Py_file_input, 65 | result, result); 66 | Py_XDECREF(x); 67 | 68 | error: 69 | if (PyErr_Occurred()) 70 | { 71 | PyErr_WriteUnraisable(Py_None); 72 | PyErr_Clear(); 73 | } 74 | return result; 75 | } 76 | 77 | #pragma comment(lib, "user32.lib") 78 | 79 | static DWORD WINAPI _cffi_bootstrap_dialog(LPVOID ignored) 80 | { 81 | Sleep(666); /* may be interrupted if the whole process is closing */ 82 | #if PY_MAJOR_VERSION >= 3 83 | MessageBoxW(NULL, (wchar_t *)_cffi_bootstrap_text, 84 | L"Python-CFFI error", 85 | MB_OK | MB_ICONERROR); 86 | #else 87 | MessageBoxA(NULL, (char *)_cffi_bootstrap_text, 88 | "Python-CFFI error", 89 | MB_OK | MB_ICONERROR); 90 | #endif 91 | _cffi_bootstrap_text = NULL; 92 | return 0; 93 | } 94 | 95 | static void _cffi_stop_error_capture(PyObject *ecap) 96 | { 97 | PyObject *s; 98 | void *text; 99 | 100 | if (ecap == (PyObject *)1) 101 | return; 102 | 103 | if (ecap == NULL) 104 | goto error; 105 | 106 | s = PyRun_String("done()", Py_eval_input, ecap, ecap); 107 | if (s == NULL) 108 | goto error; 109 | 110 | /* Show a dialog box, but in a background thread, and 111 | never show multiple dialog boxes at once. */ 112 | #if PY_MAJOR_VERSION >= 3 113 | text = PyUnicode_AsWideCharString(s, NULL); 114 | #else 115 | text = PyString_AsString(s); 116 | #endif 117 | 118 | _cffi_bootstrap_text = text; 119 | 120 | if (text != NULL) 121 | { 122 | HANDLE h; 123 | h = CreateThread(NULL, 0, _cffi_bootstrap_dialog, 124 | NULL, 0, NULL); 125 | if (h != NULL) 126 | CloseHandle(h); 127 | } 128 | /* decref the string, but it should stay alive as 'fl.buf' 129 | in the small module above. It will really be freed only if 130 | we later get another similar error. So it's a leak of at 131 | most one copy of the small module. That's fine for this 132 | situation which is usually a "fatal error" anyway. */ 133 | Py_DECREF(s); 134 | PyErr_Clear(); 135 | return; 136 | 137 | error: 138 | _cffi_bootstrap_text = NULL; 139 | PyErr_Clear(); 140 | } 141 | 142 | #else 143 | 144 | static PyObject *_cffi_start_error_capture(void) { return NULL; } 145 | static void _cffi_stop_error_capture(PyObject *ecap) { } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/cffi/commontypes.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from . import model 3 | from .error import FFIError 4 | 5 | 6 | COMMON_TYPES = {} 7 | 8 | try: 9 | # fetch "bool" and all simple Windows types 10 | from _cffi_backend import _get_common_types 11 | _get_common_types(COMMON_TYPES) 12 | except ImportError: 13 | pass 14 | 15 | COMMON_TYPES['FILE'] = model.unknown_type('FILE', '_IO_FILE') 16 | COMMON_TYPES['bool'] = '_Bool' # in case we got ImportError above 17 | 18 | for _type in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 19 | if _type.endswith('_t'): 20 | COMMON_TYPES[_type] = _type 21 | del _type 22 | 23 | _CACHE = {} 24 | 25 | def resolve_common_type(parser, commontype): 26 | try: 27 | return _CACHE[commontype] 28 | except KeyError: 29 | cdecl = COMMON_TYPES.get(commontype, commontype) 30 | if not isinstance(cdecl, str): 31 | result, quals = cdecl, 0 # cdecl is already a BaseType 32 | elif cdecl in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 33 | result, quals = model.PrimitiveType(cdecl), 0 34 | elif cdecl == 'set-unicode-needed': 35 | raise FFIError("The Windows type %r is only available after " 36 | "you call ffi.set_unicode()" % (commontype,)) 37 | else: 38 | if commontype == cdecl: 39 | raise FFIError( 40 | "Unsupported type: %r. Please look at " 41 | "http://cffi.readthedocs.io/en/latest/cdef.html#ffi-cdef-limitations " 42 | "and file an issue if you think this type should really " 43 | "be supported." % (commontype,)) 44 | result, quals = parser.parse_type_and_quals(cdecl) # recursive 45 | 46 | assert isinstance(result, model.BaseTypeByIdentity) 47 | _CACHE[commontype] = result, quals 48 | return result, quals 49 | 50 | 51 | # ____________________________________________________________ 52 | # extra types for Windows (most of them are in commontypes.c) 53 | 54 | 55 | def win_common_types(): 56 | return { 57 | "UNICODE_STRING": model.StructType( 58 | "_UNICODE_STRING", 59 | ["Length", 60 | "MaximumLength", 61 | "Buffer"], 62 | [model.PrimitiveType("unsigned short"), 63 | model.PrimitiveType("unsigned short"), 64 | model.PointerType(model.PrimitiveType("wchar_t"))], 65 | [-1, -1, -1]), 66 | "PUNICODE_STRING": "UNICODE_STRING *", 67 | "PCUNICODE_STRING": "const UNICODE_STRING *", 68 | 69 | "TBYTE": "set-unicode-needed", 70 | "TCHAR": "set-unicode-needed", 71 | "LPCTSTR": "set-unicode-needed", 72 | "PCTSTR": "set-unicode-needed", 73 | "LPTSTR": "set-unicode-needed", 74 | "PTSTR": "set-unicode-needed", 75 | "PTBYTE": "set-unicode-needed", 76 | "PTCHAR": "set-unicode-needed", 77 | } 78 | 79 | if sys.platform == 'win32': 80 | COMMON_TYPES.update(win_common_types()) 81 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/cffi/error.py: -------------------------------------------------------------------------------- 1 | 2 | class FFIError(Exception): 3 | __module__ = 'cffi' 4 | 5 | class CDefError(Exception): 6 | __module__ = 'cffi' 7 | def __str__(self): 8 | try: 9 | current_decl = self.args[1] 10 | filename = current_decl.coord.file 11 | linenum = current_decl.coord.line 12 | prefix = '%s:%d: ' % (filename, linenum) 13 | except (AttributeError, TypeError, IndexError): 14 | prefix = '' 15 | return '%s%s' % (prefix, self.args[0]) 16 | 17 | class VerificationError(Exception): 18 | """ An error raised when verification fails 19 | """ 20 | __module__ = 'cffi' 21 | 22 | class VerificationMissing(Exception): 23 | """ An error raised when incomplete structures are passed into 24 | cdef, but no verification has been done 25 | """ 26 | __module__ = 'cffi' 27 | 28 | class PkgConfigError(Exception): 29 | """ An error raised for missing modules in pkg-config 30 | """ 31 | __module__ = 'cffi' 32 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/cffi/ffiplatform.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | from .error import VerificationError 3 | 4 | 5 | LIST_OF_FILE_NAMES = ['sources', 'include_dirs', 'library_dirs', 6 | 'extra_objects', 'depends'] 7 | 8 | def get_extension(srcfilename, modname, sources=(), **kwds): 9 | _hack_at_distutils() 10 | from distutils.core import Extension 11 | allsources = [srcfilename] 12 | for src in sources: 13 | allsources.append(os.path.normpath(src)) 14 | return Extension(name=modname, sources=allsources, **kwds) 15 | 16 | def compile(tmpdir, ext, compiler_verbose=0, debug=None): 17 | """Compile a C extension module using distutils.""" 18 | 19 | _hack_at_distutils() 20 | saved_environ = os.environ.copy() 21 | try: 22 | outputfilename = _build(tmpdir, ext, compiler_verbose, debug) 23 | outputfilename = os.path.abspath(outputfilename) 24 | finally: 25 | # workaround for a distutils bugs where some env vars can 26 | # become longer and longer every time it is used 27 | for key, value in saved_environ.items(): 28 | if os.environ.get(key) != value: 29 | os.environ[key] = value 30 | return outputfilename 31 | 32 | def _build(tmpdir, ext, compiler_verbose=0, debug=None): 33 | # XXX compact but horrible :-( 34 | from distutils.core import Distribution 35 | import distutils.errors, distutils.log 36 | # 37 | dist = Distribution({'ext_modules': [ext]}) 38 | dist.parse_config_files() 39 | options = dist.get_option_dict('build_ext') 40 | if debug is None: 41 | debug = sys.flags.debug 42 | options['debug'] = ('ffiplatform', debug) 43 | options['force'] = ('ffiplatform', True) 44 | options['build_lib'] = ('ffiplatform', tmpdir) 45 | options['build_temp'] = ('ffiplatform', tmpdir) 46 | # 47 | try: 48 | old_level = distutils.log.set_threshold(0) or 0 49 | try: 50 | distutils.log.set_verbosity(compiler_verbose) 51 | dist.run_command('build_ext') 52 | cmd_obj = dist.get_command_obj('build_ext') 53 | [soname] = cmd_obj.get_outputs() 54 | finally: 55 | distutils.log.set_threshold(old_level) 56 | except (distutils.errors.CompileError, 57 | distutils.errors.LinkError) as e: 58 | raise VerificationError('%s: %s' % (e.__class__.__name__, e)) 59 | # 60 | return soname 61 | 62 | try: 63 | from os.path import samefile 64 | except ImportError: 65 | def samefile(f1, f2): 66 | return os.path.abspath(f1) == os.path.abspath(f2) 67 | 68 | def maybe_relative_path(path): 69 | if not os.path.isabs(path): 70 | return path # already relative 71 | dir = path 72 | names = [] 73 | while True: 74 | prevdir = dir 75 | dir, name = os.path.split(prevdir) 76 | if dir == prevdir or not dir: 77 | return path # failed to make it relative 78 | names.append(name) 79 | try: 80 | if samefile(dir, os.curdir): 81 | names.reverse() 82 | return os.path.join(*names) 83 | except OSError: 84 | pass 85 | 86 | # ____________________________________________________________ 87 | 88 | try: 89 | int_or_long = (int, long) 90 | import cStringIO 91 | except NameError: 92 | int_or_long = int # Python 3 93 | import io as cStringIO 94 | 95 | def _flatten(x, f): 96 | if isinstance(x, str): 97 | f.write('%ds%s' % (len(x), x)) 98 | elif isinstance(x, dict): 99 | keys = sorted(x.keys()) 100 | f.write('%dd' % len(keys)) 101 | for key in keys: 102 | _flatten(key, f) 103 | _flatten(x[key], f) 104 | elif isinstance(x, (list, tuple)): 105 | f.write('%dl' % len(x)) 106 | for value in x: 107 | _flatten(value, f) 108 | elif isinstance(x, int_or_long): 109 | f.write('%di' % (x,)) 110 | else: 111 | raise TypeError( 112 | "the keywords to verify() contains unsupported object %r" % (x,)) 113 | 114 | def flatten(x): 115 | f = cStringIO.StringIO() 116 | _flatten(x, f) 117 | return f.getvalue() 118 | 119 | def _hack_at_distutils(): 120 | # Windows-only workaround for some configurations: see 121 | # https://bugs.python.org/issue23246 (Python 2.7 with 122 | # a specific MS compiler suite download) 123 | if sys.platform == "win32": 124 | try: 125 | import setuptools # for side-effects, patches distutils 126 | except ImportError: 127 | pass 128 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/cffi/lock.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info < (3,): 4 | try: 5 | from thread import allocate_lock 6 | except ImportError: 7 | from dummy_thread import allocate_lock 8 | else: 9 | try: 10 | from _thread import allocate_lock 11 | except ImportError: 12 | from _dummy_thread import allocate_lock 13 | 14 | 15 | ##import sys 16 | ##l1 = allocate_lock 17 | 18 | ##class allocate_lock(object): 19 | ## def __init__(self): 20 | ## self._real = l1() 21 | ## def __enter__(self): 22 | ## for i in range(4, 0, -1): 23 | ## print sys._getframe(i).f_code 24 | ## print 25 | ## return self._real.__enter__() 26 | ## def __exit__(self, *args): 27 | ## return self._real.__exit__(*args) 28 | ## def acquire(self, f): 29 | ## assert f is False 30 | ## return self._real.acquire(f) 31 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/cffi/pkgconfig.py: -------------------------------------------------------------------------------- 1 | # pkg-config, https://www.freedesktop.org/wiki/Software/pkg-config/ integration for cffi 2 | import sys, os, subprocess 3 | 4 | from .error import PkgConfigError 5 | 6 | 7 | def merge_flags(cfg1, cfg2): 8 | """Merge values from cffi config flags cfg2 to cf1 9 | 10 | Example: 11 | merge_flags({"libraries": ["one"]}, {"libraries": ["two"]}) 12 | {"libraries": ["one", "two"]} 13 | """ 14 | for key, value in cfg2.items(): 15 | if key not in cfg1: 16 | cfg1[key] = value 17 | else: 18 | if not isinstance(cfg1[key], list): 19 | raise TypeError("cfg1[%r] should be a list of strings" % (key,)) 20 | if not isinstance(value, list): 21 | raise TypeError("cfg2[%r] should be a list of strings" % (key,)) 22 | cfg1[key].extend(value) 23 | return cfg1 24 | 25 | 26 | def call(libname, flag, encoding=sys.getfilesystemencoding()): 27 | """Calls pkg-config and returns the output if found 28 | """ 29 | a = ["pkg-config", "--print-errors"] 30 | a.append(flag) 31 | a.append(libname) 32 | try: 33 | pc = subprocess.Popen(a, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 34 | except EnvironmentError as e: 35 | raise PkgConfigError("cannot run pkg-config: %s" % (str(e).strip(),)) 36 | 37 | bout, berr = pc.communicate() 38 | if pc.returncode != 0: 39 | try: 40 | berr = berr.decode(encoding) 41 | except Exception: 42 | pass 43 | raise PkgConfigError(berr.strip()) 44 | 45 | if sys.version_info >= (3,) and not isinstance(bout, str): # Python 3.x 46 | try: 47 | bout = bout.decode(encoding) 48 | except UnicodeDecodeError: 49 | raise PkgConfigError("pkg-config %s %s returned bytes that cannot " 50 | "be decoded with encoding %r:\n%r" % 51 | (flag, libname, encoding, bout)) 52 | 53 | if os.altsep != '\\' and '\\' in bout: 54 | raise PkgConfigError("pkg-config %s %s returned an unsupported " 55 | "backslash-escaped output:\n%r" % 56 | (flag, libname, bout)) 57 | return bout 58 | 59 | 60 | def flags_from_pkgconfig(libs): 61 | r"""Return compiler line flags for FFI.set_source based on pkg-config output 62 | 63 | Usage 64 | ... 65 | ffibuilder.set_source("_foo", pkgconfig = ["libfoo", "libbar >= 1.8.3"]) 66 | 67 | If pkg-config is installed on build machine, then arguments include_dirs, 68 | library_dirs, libraries, define_macros, extra_compile_args and 69 | extra_link_args are extended with an output of pkg-config for libfoo and 70 | libbar. 71 | 72 | Raises PkgConfigError in case the pkg-config call fails. 73 | """ 74 | 75 | def get_include_dirs(string): 76 | return [x[2:] for x in string.split() if x.startswith("-I")] 77 | 78 | def get_library_dirs(string): 79 | return [x[2:] for x in string.split() if x.startswith("-L")] 80 | 81 | def get_libraries(string): 82 | return [x[2:] for x in string.split() if x.startswith("-l")] 83 | 84 | # convert -Dfoo=bar to list of tuples [("foo", "bar")] expected by distutils 85 | def get_macros(string): 86 | def _macro(x): 87 | x = x[2:] # drop "-D" 88 | if '=' in x: 89 | return tuple(x.split("=", 1)) # "-Dfoo=bar" => ("foo", "bar") 90 | else: 91 | return (x, None) # "-Dfoo" => ("foo", None) 92 | return [_macro(x) for x in string.split() if x.startswith("-D")] 93 | 94 | def get_other_cflags(string): 95 | return [x for x in string.split() if not x.startswith("-I") and 96 | not x.startswith("-D")] 97 | 98 | def get_other_libs(string): 99 | return [x for x in string.split() if not x.startswith("-L") and 100 | not x.startswith("-l")] 101 | 102 | # return kwargs for given libname 103 | def kwargs(libname): 104 | fse = sys.getfilesystemencoding() 105 | all_cflags = call(libname, "--cflags") 106 | all_libs = call(libname, "--libs") 107 | return { 108 | "include_dirs": get_include_dirs(all_cflags), 109 | "library_dirs": get_library_dirs(all_libs), 110 | "libraries": get_libraries(all_libs), 111 | "define_macros": get_macros(all_cflags), 112 | "extra_compile_args": get_other_cflags(all_cflags), 113 | "extra_link_args": get_other_libs(all_libs), 114 | } 115 | 116 | # merge all arguments together 117 | ret = {} 118 | for libname in libs: 119 | lib_flags = kwargs(libname) 120 | merge_flags(ret, lib_flags) 121 | return ret 122 | -------------------------------------------------------------------------------- /modules/common/Crypto/Cipher/py3compat.pyi: -------------------------------------------------------------------------------- 1 | from typing import Union, Any, Optional, IO 2 | 3 | Buffer = Union[bytes, bytearray, memoryview] 4 | 5 | import sys 6 | 7 | def b(s: str) -> bytes: ... 8 | def bchr(s: int) -> bytes: ... 9 | def bord(s: bytes) -> int: ... 10 | def tobytes(s: Union[bytes, str]) -> bytes: ... 11 | def tostr(b: bytes) -> str: ... 12 | def bytestring(x: Any) -> bool: ... 13 | 14 | def is_native_int(s: Any) -> bool: ... 15 | def is_string(x: Any) -> bool: ... 16 | 17 | def BytesIO(b: bytes) -> IO[bytes]: ... 18 | 19 | if sys.version_info[0] == 2: 20 | from sys import maxint 21 | iter_range = xrange 22 | 23 | if sys.version_info[1] < 7: 24 | import types 25 | _memoryview = types.NoneType 26 | else: 27 | _memoryview = memoryview 28 | 29 | else: 30 | from sys import maxsize as maxint 31 | iter_range = range 32 | 33 | _memoryview = memoryview 34 | 35 | def _copy_bytes(start: Optional[int], end: Optional[int], seq: Buffer) -> bytes: ... 36 | -------------------------------------------------------------------------------- /modules/common/Crypto/Util/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # =================================================================== 4 | # The contents of this file are dedicated to the public domain. To 5 | # the extent that dedication to the public domain is not available, 6 | # everyone is granted a worldwide, perpetual, royalty-free, 7 | # non-exclusive license to exercise all rights associated with the 8 | # contents of this file for any purpose whatsoever. 9 | # No rights are reserved. 10 | # 11 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 12 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 14 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 15 | # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 16 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 17 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18 | # SOFTWARE. 19 | # =================================================================== 20 | 21 | """Miscellaneous modules 22 | 23 | Contains useful modules that don't belong into any of the 24 | other Crypto.* subpackages. 25 | 26 | ======================== ============================================= 27 | Module Description 28 | ======================== ============================================= 29 | `Crypto.Util.number` Number-theoretic functions (primality testing, etc.) 30 | `Crypto.Util.Counter` Fast counter functions for CTR cipher modes. 31 | `Crypto.Util.RFC1751` Converts between 128-bit keys and human-readable 32 | strings of words. 33 | `Crypto.Util.asn1` Minimal support for ASN.1 DER encoding 34 | `Crypto.Util.Padding` Set of functions for adding and removing padding. 35 | ======================== ============================================= 36 | 37 | :undocumented: _galois, _number_new, cpuid, py3compat, _raw_api 38 | """ 39 | 40 | __all__ = ['RFC1751', 'number', 'strxor', 'asn1', 'Counter', 'Padding'] 41 | 42 | -------------------------------------------------------------------------------- /modules/common/Crypto/Util/_cpuid_c.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Util/_cpuid_c.so -------------------------------------------------------------------------------- /modules/common/Crypto/Util/_cpuid_c_arm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/Crypto/Util/_cpuid_c_arm.so -------------------------------------------------------------------------------- /modules/common/Crypto/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['Cipher', 'Hash', 'Protocol', 'PublicKey', 'Util', 'Signature', 2 | 'IO', 'Math'] 3 | 4 | version_info = (3, 8, '0') 5 | 6 | __version__ = ".".join([str(x) for x in version_info]) 7 | -------------------------------------------------------------------------------- /modules/common/Crypto/__init__.pyi: -------------------------------------------------------------------------------- 1 | from typing import Tuple, Union 2 | 3 | version_info : Tuple[int, int, Union[int, str]] 4 | __version__ : str 5 | -------------------------------------------------------------------------------- /modules/common/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | -------------------------------------------------------------------------------- /modules/common/dateutil/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | try: 3 | from ._version import version as __version__ 4 | except ImportError: 5 | __version__ = 'unknown' 6 | 7 | __all__ = ['easter', 'parser', 'relativedelta', 'rrule', 'tz', 8 | 'utils', 'zoneinfo'] 9 | -------------------------------------------------------------------------------- /modules/common/dateutil/_common.py: -------------------------------------------------------------------------------- 1 | """ 2 | Common code used in multiple modules. 3 | """ 4 | 5 | 6 | class weekday(object): 7 | __slots__ = ["weekday", "n"] 8 | 9 | def __init__(self, weekday, n=None): 10 | self.weekday = weekday 11 | self.n = n 12 | 13 | def __call__(self, n): 14 | if n == self.n: 15 | return self 16 | else: 17 | return self.__class__(self.weekday, n) 18 | 19 | def __eq__(self, other): 20 | try: 21 | if self.weekday != other.weekday or self.n != other.n: 22 | return False 23 | except AttributeError: 24 | return False 25 | return True 26 | 27 | def __hash__(self): 28 | return hash(( 29 | self.weekday, 30 | self.n, 31 | )) 32 | 33 | def __ne__(self, other): 34 | return not (self == other) 35 | 36 | def __repr__(self): 37 | s = ("MO", "TU", "WE", "TH", "FR", "SA", "SU")[self.weekday] 38 | if not self.n: 39 | return s 40 | else: 41 | return "%s(%+d)" % (s, self.n) 42 | 43 | # vim:ts=4:sw=4:et 44 | -------------------------------------------------------------------------------- /modules/common/dateutil/parser/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from ._parser import parse, parser, parserinfo, ParserError 3 | from ._parser import DEFAULTPARSER, DEFAULTTZPARSER 4 | from ._parser import UnknownTimezoneWarning 5 | 6 | from ._parser import __doc__ 7 | 8 | from .isoparser import isoparser, isoparse 9 | 10 | __all__ = ['parse', 'parser', 'parserinfo', 11 | 'isoparse', 'isoparser', 12 | 'ParserError', 13 | 'UnknownTimezoneWarning'] 14 | 15 | 16 | ### 17 | # Deprecate portions of the private interface so that downstream code that 18 | # is improperly relying on it is given *some* notice. 19 | 20 | 21 | def __deprecated_private_func(f): 22 | from functools import wraps 23 | import warnings 24 | 25 | msg = ('{name} is a private function and may break without warning, ' 26 | 'it will be moved and or renamed in future versions.') 27 | msg = msg.format(name=f.__name__) 28 | 29 | @wraps(f) 30 | def deprecated_func(*args, **kwargs): 31 | warnings.warn(msg, DeprecationWarning) 32 | return f(*args, **kwargs) 33 | 34 | return deprecated_func 35 | 36 | def __deprecate_private_class(c): 37 | import warnings 38 | 39 | msg = ('{name} is a private class and may break without warning, ' 40 | 'it will be moved and or renamed in future versions.') 41 | msg = msg.format(name=c.__name__) 42 | 43 | class private_class(c): 44 | __doc__ = c.__doc__ 45 | 46 | def __init__(self, *args, **kwargs): 47 | warnings.warn(msg, DeprecationWarning) 48 | super(private_class, self).__init__(*args, **kwargs) 49 | 50 | private_class.__name__ = c.__name__ 51 | 52 | return private_class 53 | 54 | 55 | from ._parser import _timelex, _resultbase 56 | from ._parser import _tzparser, _parsetz 57 | 58 | _timelex = __deprecate_private_class(_timelex) 59 | _tzparser = __deprecate_private_class(_tzparser) 60 | _resultbase = __deprecate_private_class(_resultbase) 61 | _parsetz = __deprecated_private_func(_parsetz) 62 | -------------------------------------------------------------------------------- /modules/common/dateutil/tz/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from .tz import * 3 | from .tz import __doc__ 4 | 5 | __all__ = ["tzutc", "tzoffset", "tzlocal", "tzfile", "tzrange", 6 | "tzstr", "tzical", "tzwin", "tzwinlocal", "gettz", 7 | "enfold", "datetime_ambiguous", "datetime_exists", 8 | "resolve_imaginary", "UTC", "DeprecatedTzFormatWarning"] 9 | 10 | 11 | class DeprecatedTzFormatWarning(Warning): 12 | """Warning raised when time zones are parsed from deprecated formats.""" 13 | -------------------------------------------------------------------------------- /modules/common/dateutil/tz/_factories.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta 2 | import weakref 3 | from collections import OrderedDict 4 | 5 | 6 | class _TzSingleton(type): 7 | def __init__(cls, *args, **kwargs): 8 | cls.__instance = None 9 | super(_TzSingleton, cls).__init__(*args, **kwargs) 10 | 11 | def __call__(cls): 12 | if cls.__instance is None: 13 | cls.__instance = super(_TzSingleton, cls).__call__() 14 | return cls.__instance 15 | 16 | 17 | class _TzFactory(type): 18 | def instance(cls, *args, **kwargs): 19 | """Alternate constructor that returns a fresh instance""" 20 | return type.__call__(cls, *args, **kwargs) 21 | 22 | 23 | class _TzOffsetFactory(_TzFactory): 24 | def __init__(cls, *args, **kwargs): 25 | cls.__instances = weakref.WeakValueDictionary() 26 | cls.__strong_cache = OrderedDict() 27 | cls.__strong_cache_size = 8 28 | 29 | def __call__(cls, name, offset): 30 | if isinstance(offset, timedelta): 31 | key = (name, offset.total_seconds()) 32 | else: 33 | key = (name, offset) 34 | 35 | instance = cls.__instances.get(key, None) 36 | if instance is None: 37 | instance = cls.__instances.setdefault(key, 38 | cls.instance(name, offset)) 39 | 40 | cls.__strong_cache[key] = cls.__strong_cache.pop(key, instance) 41 | 42 | # Remove an item if the strong cache is overpopulated 43 | # TODO: Maybe this should be under a lock? 44 | if len(cls.__strong_cache) > cls.__strong_cache_size: 45 | cls.__strong_cache.popitem(last=False) 46 | 47 | return instance 48 | 49 | 50 | class _TzStrFactory(_TzFactory): 51 | def __init__(cls, *args, **kwargs): 52 | cls.__instances = weakref.WeakValueDictionary() 53 | cls.__strong_cache = OrderedDict() 54 | cls.__strong_cache_size = 8 55 | 56 | def __call__(cls, s, posix_offset=False): 57 | key = (s, posix_offset) 58 | instance = cls.__instances.get(key, None) 59 | 60 | if instance is None: 61 | instance = cls.__instances.setdefault(key, 62 | cls.instance(s, posix_offset)) 63 | 64 | cls.__strong_cache[key] = cls.__strong_cache.pop(key, instance) 65 | 66 | 67 | # Remove an item if the strong cache is overpopulated 68 | # TODO: Maybe this should be under a lock? 69 | if len(cls.__strong_cache) > cls.__strong_cache_size: 70 | cls.__strong_cache.popitem(last=False) 71 | 72 | return instance 73 | 74 | -------------------------------------------------------------------------------- /modules/common/dateutil/tzwin.py: -------------------------------------------------------------------------------- 1 | # tzwin has moved to dateutil.tz.win 2 | from .tz.win import * 3 | -------------------------------------------------------------------------------- /modules/common/dep/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/dep/__init__.py -------------------------------------------------------------------------------- /modules/common/dep/_cffi_backend.cpython-37m-darwin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/dep/_cffi_backend.cpython-37m-darwin.so -------------------------------------------------------------------------------- /modules/common/dep/_cffi_backend.cpython-38-darwin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/dep/_cffi_backend.cpython-38-darwin.so -------------------------------------------------------------------------------- /modules/common/dep/_cffi_backend.cpython-39-darwin.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/dep/_cffi_backend.cpython-39-darwin.so -------------------------------------------------------------------------------- /modules/common/dep/bin/xattr: -------------------------------------------------------------------------------- 1 | #!/Users/amartinez/code/projects/automactc-release/env/bin/python3 2 | # -*- coding: utf-8 -*- 3 | import re 4 | import sys 5 | 6 | from xattr.tool import main 7 | 8 | if __name__ == '__main__': 9 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 10 | sys.exit(main()) 11 | -------------------------------------------------------------------------------- /modules/common/dep/cffi-1.14.0.dist-info/INSTALLER: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /modules/common/dep/cffi-1.14.0.dist-info/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Except when otherwise stated (look for LICENSE files in directories or 3 | information at the beginning of each file) all software and 4 | documentation is licensed as follows: 5 | 6 | The MIT License 7 | 8 | Permission is hereby granted, free of charge, to any person 9 | obtaining a copy of this software and associated documentation 10 | files (the "Software"), to deal in the Software without 11 | restriction, including without limitation the rights to use, 12 | copy, modify, merge, publish, distribute, sublicense, and/or 13 | sell copies of the Software, and to permit persons to whom the 14 | Software is furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included 17 | in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | 27 | -------------------------------------------------------------------------------- /modules/common/dep/cffi-1.14.0.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: cffi 3 | Version: 1.14.0 4 | Summary: Foreign Function Interface for Python calling C code. 5 | Home-page: http://cffi.readthedocs.org 6 | Author: Armin Rigo, Maciej Fijalkowski 7 | Author-email: python-cffi@googlegroups.com 8 | License: MIT 9 | Platform: UNKNOWN 10 | Classifier: Programming Language :: Python 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 2.6 13 | Classifier: Programming Language :: Python :: 2.7 14 | Classifier: Programming Language :: Python :: 3 15 | Classifier: Programming Language :: Python :: 3.2 16 | Classifier: Programming Language :: Python :: 3.3 17 | Classifier: Programming Language :: Python :: 3.4 18 | Classifier: Programming Language :: Python :: 3.5 19 | Classifier: Programming Language :: Python :: 3.6 20 | Classifier: Programming Language :: Python :: Implementation :: CPython 21 | Classifier: Programming Language :: Python :: Implementation :: PyPy 22 | Classifier: License :: OSI Approved :: MIT License 23 | Requires-Dist: pycparser 24 | 25 | 26 | CFFI 27 | ==== 28 | 29 | Foreign Function Interface for Python calling C code. 30 | Please see the `Documentation `_. 31 | 32 | Contact 33 | ------- 34 | 35 | `Mailing list `_ 36 | 37 | 38 | -------------------------------------------------------------------------------- /modules/common/dep/cffi-1.14.0.dist-info/RECORD: -------------------------------------------------------------------------------- 1 | _cffi_backend.cpython-37m-darwin.so,sha256=CVKRa3hgut8WGHFeot7aLwe6o3_zdHH78rvGfR_b6oE,196704 2 | cffi-1.14.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 3 | cffi-1.14.0.dist-info/LICENSE,sha256=BLgPWwd7vtaICM_rreteNSPyqMmpZJXFh72W3x6sKjM,1294 4 | cffi-1.14.0.dist-info/METADATA,sha256=tZUQbfePzTlM58vXdkcDc1ID5OsPswm6VNj3Ds5VzRU,1191 5 | cffi-1.14.0.dist-info/RECORD,, 6 | cffi-1.14.0.dist-info/WHEEL,sha256=ePSmKDYpHLRUYc6QuHiYMO-IoN8XmQMJmY2AHxzV4Bc,110 7 | cffi-1.14.0.dist-info/entry_points.txt,sha256=Q9f5C9IpjYxo0d2PK9eUcnkgxHc9pHWwjEMaANPKNCI,76 8 | cffi-1.14.0.dist-info/top_level.txt,sha256=rE7WR3rZfNKxWI9-jn6hsHCAl7MDkB-FmuQbxWjFehQ,19 9 | cffi/__init__.py,sha256=-y8bWPqUv21omj4J-aRMkCvPSGHjIkGa8uhUOjX0bwg,513 10 | cffi/__pycache__/__init__.cpython-37.pyc,, 11 | cffi/__pycache__/api.cpython-37.pyc,, 12 | cffi/__pycache__/backend_ctypes.cpython-37.pyc,, 13 | cffi/__pycache__/cffi_opcode.cpython-37.pyc,, 14 | cffi/__pycache__/commontypes.cpython-37.pyc,, 15 | cffi/__pycache__/cparser.cpython-37.pyc,, 16 | cffi/__pycache__/error.cpython-37.pyc,, 17 | cffi/__pycache__/ffiplatform.cpython-37.pyc,, 18 | cffi/__pycache__/lock.cpython-37.pyc,, 19 | cffi/__pycache__/model.cpython-37.pyc,, 20 | cffi/__pycache__/pkgconfig.cpython-37.pyc,, 21 | cffi/__pycache__/recompiler.cpython-37.pyc,, 22 | cffi/__pycache__/setuptools_ext.cpython-37.pyc,, 23 | cffi/__pycache__/vengine_cpy.cpython-37.pyc,, 24 | cffi/__pycache__/vengine_gen.cpython-37.pyc,, 25 | cffi/__pycache__/verifier.cpython-37.pyc,, 26 | cffi/_cffi_errors.h,sha256=6nFQ-4dRQI1bXRoSeqdvyKU33TmutQJB_2fAhWSzdl8,3856 27 | cffi/_cffi_include.h,sha256=6AXjqsFDXLw7jnnaXIPM6zfzXH4R_HoviiFUwdwUG0Q,13482 28 | cffi/_embedding.h,sha256=IYX3vrLk6nLIwwmF-MrvRVOreVenHdk5oGMBdJn2S3Y,17411 29 | cffi/api.py,sha256=yxJalIePbr1mz_WxAHokSwyP5CVYde44m-nolHnbJNo,42064 30 | cffi/backend_ctypes.py,sha256=h5ZIzLc6BFVXnGyc9xPqZWUS7qGy7yFSDqXe68Sa8z4,42454 31 | cffi/cffi_opcode.py,sha256=v9RdD_ovA8rCtqsC95Ivki5V667rAOhGgs3fb2q9xpM,5724 32 | cffi/commontypes.py,sha256=QS4uxCDI7JhtTyjh1hlnCA-gynmaszWxJaRRLGkJa1A,2689 33 | cffi/cparser.py,sha256=l4Hy6H2H3q4-0-Mv-5ld3mkH4qRFybWz2CTwNUtNpw0,42071 34 | cffi/error.py,sha256=v6xTiS4U0kvDcy4h_BDRo5v39ZQuj-IMRYLv5ETddZs,877 35 | cffi/ffiplatform.py,sha256=HMXqR8ks2wtdsNxGaWpQ_PyqIvtiuos_vf1qKCy-cwg,4046 36 | cffi/lock.py,sha256=l9TTdwMIMpi6jDkJGnQgE9cvTIR7CAntIJr8EGHt3pY,747 37 | cffi/model.py,sha256=AYyjS26uiFKXtkm43qmStpy9zfGh5HVJF4UETYFBt6w,21682 38 | cffi/parse_c_type.h,sha256=OdwQfwM9ktq6vlCB43exFQmxDBtj2MBNdK8LYl15tjw,5976 39 | cffi/pkgconfig.py,sha256=LP1w7vmWvmKwyqLaU1Z243FOWGNQMrgMUZrvgFuOlco,4374 40 | cffi/recompiler.py,sha256=R7_zy3AuBZHT_WcJ2C6V-NjMhl_I9lYOSP3FdIOQdCQ,63217 41 | cffi/setuptools_ext.py,sha256=qc6arfrSzm4RNT5oJz6d5td7KJ-pHfI7bqYD0X4Q-08,8848 42 | cffi/vengine_cpy.py,sha256=IiwNMd8gxKt1z9zYNNw-Q8vgf_DK8v5mdCJvidrZHzY,43314 43 | cffi/vengine_gen.py,sha256=Zkq0-EdeZwn6qUvf_CI8iUEs2UxVIvDmKCH1j0-y0GI,26676 44 | cffi/verifier.py,sha256=J9Enz2rbJb9CHPqWlWQ5uQESoyr0uc7MNWugchjXBv4,11207 45 | -------------------------------------------------------------------------------- /modules/common/dep/cffi-1.14.0.dist-info/WHEEL: -------------------------------------------------------------------------------- 1 | Wheel-Version: 1.0 2 | Generator: bdist_wheel (0.34.2) 3 | Root-Is-Purelib: false 4 | Tag: cp37-cp37m-macosx_10_9_x86_64 5 | 6 | -------------------------------------------------------------------------------- /modules/common/dep/cffi-1.14.0.dist-info/entry_points.txt: -------------------------------------------------------------------------------- 1 | [distutils.setup_keywords] 2 | cffi_modules = cffi.setuptools_ext:cffi_modules 3 | 4 | -------------------------------------------------------------------------------- /modules/common/dep/cffi-1.14.0.dist-info/top_level.txt: -------------------------------------------------------------------------------- 1 | _cffi_backend 2 | cffi 3 | -------------------------------------------------------------------------------- /modules/common/dep/cffi37/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['FFI', 'VerificationError', 'VerificationMissing', 'CDefError', 2 | 'FFIError'] 3 | 4 | from .api import FFI 5 | from .error import CDefError, FFIError, VerificationError, VerificationMissing 6 | from .error import PkgConfigError 7 | 8 | __version__ = "1.14.0" 9 | __version_info__ = (1, 14, 0) 10 | 11 | # The verifier module file names are based on the CRC32 of a string that 12 | # contains the following version number. It may be older than __version__ 13 | # if nothing is clearly incompatible. 14 | __version_verifier_modules__ = "0.8.6" 15 | -------------------------------------------------------------------------------- /modules/common/dep/cffi37/_cffi_errors.h: -------------------------------------------------------------------------------- 1 | #ifndef CFFI_MESSAGEBOX 2 | # ifdef _MSC_VER 3 | # define CFFI_MESSAGEBOX 1 4 | # else 5 | # define CFFI_MESSAGEBOX 0 6 | # endif 7 | #endif 8 | 9 | 10 | #if CFFI_MESSAGEBOX 11 | /* Windows only: logic to take the Python-CFFI embedding logic 12 | initialization errors and display them in a background thread 13 | with MessageBox. The idea is that if the whole program closes 14 | as a result of this problem, then likely it is already a console 15 | program and you can read the stderr output in the console too. 16 | If it is not a console program, then it will likely show its own 17 | dialog to complain, or generally not abruptly close, and for this 18 | case the background thread should stay alive. 19 | */ 20 | static void *volatile _cffi_bootstrap_text; 21 | 22 | static PyObject *_cffi_start_error_capture(void) 23 | { 24 | PyObject *result = NULL; 25 | PyObject *x, *m, *bi; 26 | 27 | if (InterlockedCompareExchangePointer(&_cffi_bootstrap_text, 28 | (void *)1, NULL) != NULL) 29 | return (PyObject *)1; 30 | 31 | m = PyImport_AddModule("_cffi_error_capture"); 32 | if (m == NULL) 33 | goto error; 34 | 35 | result = PyModule_GetDict(m); 36 | if (result == NULL) 37 | goto error; 38 | 39 | #if PY_MAJOR_VERSION >= 3 40 | bi = PyImport_ImportModule("builtins"); 41 | #else 42 | bi = PyImport_ImportModule("__builtin__"); 43 | #endif 44 | if (bi == NULL) 45 | goto error; 46 | PyDict_SetItemString(result, "__builtins__", bi); 47 | Py_DECREF(bi); 48 | 49 | x = PyRun_String( 50 | "import sys\n" 51 | "class FileLike:\n" 52 | " def write(self, x):\n" 53 | " try:\n" 54 | " of.write(x)\n" 55 | " except: pass\n" 56 | " self.buf += x\n" 57 | "fl = FileLike()\n" 58 | "fl.buf = ''\n" 59 | "of = sys.stderr\n" 60 | "sys.stderr = fl\n" 61 | "def done():\n" 62 | " sys.stderr = of\n" 63 | " return fl.buf\n", /* make sure the returned value stays alive */ 64 | Py_file_input, 65 | result, result); 66 | Py_XDECREF(x); 67 | 68 | error: 69 | if (PyErr_Occurred()) 70 | { 71 | PyErr_WriteUnraisable(Py_None); 72 | PyErr_Clear(); 73 | } 74 | return result; 75 | } 76 | 77 | #pragma comment(lib, "user32.lib") 78 | 79 | static DWORD WINAPI _cffi_bootstrap_dialog(LPVOID ignored) 80 | { 81 | Sleep(666); /* may be interrupted if the whole process is closing */ 82 | #if PY_MAJOR_VERSION >= 3 83 | MessageBoxW(NULL, (wchar_t *)_cffi_bootstrap_text, 84 | L"Python-CFFI error", 85 | MB_OK | MB_ICONERROR); 86 | #else 87 | MessageBoxA(NULL, (char *)_cffi_bootstrap_text, 88 | "Python-CFFI error", 89 | MB_OK | MB_ICONERROR); 90 | #endif 91 | _cffi_bootstrap_text = NULL; 92 | return 0; 93 | } 94 | 95 | static void _cffi_stop_error_capture(PyObject *ecap) 96 | { 97 | PyObject *s; 98 | void *text; 99 | 100 | if (ecap == (PyObject *)1) 101 | return; 102 | 103 | if (ecap == NULL) 104 | goto error; 105 | 106 | s = PyRun_String("done()", Py_eval_input, ecap, ecap); 107 | if (s == NULL) 108 | goto error; 109 | 110 | /* Show a dialog box, but in a background thread, and 111 | never show multiple dialog boxes at once. */ 112 | #if PY_MAJOR_VERSION >= 3 113 | text = PyUnicode_AsWideCharString(s, NULL); 114 | #else 115 | text = PyString_AsString(s); 116 | #endif 117 | 118 | _cffi_bootstrap_text = text; 119 | 120 | if (text != NULL) 121 | { 122 | HANDLE h; 123 | h = CreateThread(NULL, 0, _cffi_bootstrap_dialog, 124 | NULL, 0, NULL); 125 | if (h != NULL) 126 | CloseHandle(h); 127 | } 128 | /* decref the string, but it should stay alive as 'fl.buf' 129 | in the small module above. It will really be freed only if 130 | we later get another similar error. So it's a leak of at 131 | most one copy of the small module. That's fine for this 132 | situation which is usually a "fatal error" anyway. */ 133 | Py_DECREF(s); 134 | PyErr_Clear(); 135 | return; 136 | 137 | error: 138 | _cffi_bootstrap_text = NULL; 139 | PyErr_Clear(); 140 | } 141 | 142 | #else 143 | 144 | static PyObject *_cffi_start_error_capture(void) { return NULL; } 145 | static void _cffi_stop_error_capture(PyObject *ecap) { } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /modules/common/dep/cffi37/commontypes.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from . import model 3 | from .error import FFIError 4 | 5 | 6 | COMMON_TYPES = {} 7 | 8 | try: 9 | # fetch "bool" and all simple Windows types 10 | from _cffi_backend import _get_common_types 11 | _get_common_types(COMMON_TYPES) 12 | except ImportError: 13 | pass 14 | 15 | COMMON_TYPES['FILE'] = model.unknown_type('FILE', '_IO_FILE') 16 | COMMON_TYPES['bool'] = '_Bool' # in case we got ImportError above 17 | 18 | for _type in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 19 | if _type.endswith('_t'): 20 | COMMON_TYPES[_type] = _type 21 | del _type 22 | 23 | _CACHE = {} 24 | 25 | def resolve_common_type(parser, commontype): 26 | try: 27 | return _CACHE[commontype] 28 | except KeyError: 29 | cdecl = COMMON_TYPES.get(commontype, commontype) 30 | if not isinstance(cdecl, str): 31 | result, quals = cdecl, 0 # cdecl is already a BaseType 32 | elif cdecl in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 33 | result, quals = model.PrimitiveType(cdecl), 0 34 | elif cdecl == 'set-unicode-needed': 35 | raise FFIError("The Windows type %r is only available after " 36 | "you call ffi.set_unicode()" % (commontype,)) 37 | else: 38 | if commontype == cdecl: 39 | raise FFIError( 40 | "Unsupported type: %r. Please look at " 41 | "http://cffi.readthedocs.io/en/latest/cdef.html#ffi-cdef-limitations " 42 | "and file an issue if you think this type should really " 43 | "be supported." % (commontype,)) 44 | result, quals = parser.parse_type_and_quals(cdecl) # recursive 45 | 46 | assert isinstance(result, model.BaseTypeByIdentity) 47 | _CACHE[commontype] = result, quals 48 | return result, quals 49 | 50 | 51 | # ____________________________________________________________ 52 | # extra types for Windows (most of them are in commontypes.c) 53 | 54 | 55 | def win_common_types(): 56 | return { 57 | "UNICODE_STRING": model.StructType( 58 | "_UNICODE_STRING", 59 | ["Length", 60 | "MaximumLength", 61 | "Buffer"], 62 | [model.PrimitiveType("unsigned short"), 63 | model.PrimitiveType("unsigned short"), 64 | model.PointerType(model.PrimitiveType("wchar_t"))], 65 | [-1, -1, -1]), 66 | "PUNICODE_STRING": "UNICODE_STRING *", 67 | "PCUNICODE_STRING": "const UNICODE_STRING *", 68 | 69 | "TBYTE": "set-unicode-needed", 70 | "TCHAR": "set-unicode-needed", 71 | "LPCTSTR": "set-unicode-needed", 72 | "PCTSTR": "set-unicode-needed", 73 | "LPTSTR": "set-unicode-needed", 74 | "PTSTR": "set-unicode-needed", 75 | "PTBYTE": "set-unicode-needed", 76 | "PTCHAR": "set-unicode-needed", 77 | } 78 | 79 | if sys.platform == 'win32': 80 | COMMON_TYPES.update(win_common_types()) 81 | -------------------------------------------------------------------------------- /modules/common/dep/cffi37/error.py: -------------------------------------------------------------------------------- 1 | 2 | class FFIError(Exception): 3 | __module__ = 'cffi' 4 | 5 | class CDefError(Exception): 6 | __module__ = 'cffi' 7 | def __str__(self): 8 | try: 9 | current_decl = self.args[1] 10 | filename = current_decl.coord.file 11 | linenum = current_decl.coord.line 12 | prefix = '%s:%d: ' % (filename, linenum) 13 | except (AttributeError, TypeError, IndexError): 14 | prefix = '' 15 | return '%s%s' % (prefix, self.args[0]) 16 | 17 | class VerificationError(Exception): 18 | """ An error raised when verification fails 19 | """ 20 | __module__ = 'cffi' 21 | 22 | class VerificationMissing(Exception): 23 | """ An error raised when incomplete structures are passed into 24 | cdef, but no verification has been done 25 | """ 26 | __module__ = 'cffi' 27 | 28 | class PkgConfigError(Exception): 29 | """ An error raised for missing modules in pkg-config 30 | """ 31 | __module__ = 'cffi' 32 | -------------------------------------------------------------------------------- /modules/common/dep/cffi37/ffiplatform.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | from .error import VerificationError 3 | 4 | 5 | LIST_OF_FILE_NAMES = ['sources', 'include_dirs', 'library_dirs', 6 | 'extra_objects', 'depends'] 7 | 8 | def get_extension(srcfilename, modname, sources=(), **kwds): 9 | _hack_at_distutils() 10 | from distutils.core import Extension 11 | allsources = [srcfilename] 12 | for src in sources: 13 | allsources.append(os.path.normpath(src)) 14 | return Extension(name=modname, sources=allsources, **kwds) 15 | 16 | def compile(tmpdir, ext, compiler_verbose=0, debug=None): 17 | """Compile a C extension module using distutils.""" 18 | 19 | _hack_at_distutils() 20 | saved_environ = os.environ.copy() 21 | try: 22 | outputfilename = _build(tmpdir, ext, compiler_verbose, debug) 23 | outputfilename = os.path.abspath(outputfilename) 24 | finally: 25 | # workaround for a distutils bugs where some env vars can 26 | # become longer and longer every time it is used 27 | for key, value in saved_environ.items(): 28 | if os.environ.get(key) != value: 29 | os.environ[key] = value 30 | return outputfilename 31 | 32 | def _build(tmpdir, ext, compiler_verbose=0, debug=None): 33 | # XXX compact but horrible :-( 34 | from distutils.core import Distribution 35 | import distutils.errors, distutils.log 36 | # 37 | dist = Distribution({'ext_modules': [ext]}) 38 | dist.parse_config_files() 39 | options = dist.get_option_dict('build_ext') 40 | if debug is None: 41 | debug = sys.flags.debug 42 | options['debug'] = ('ffiplatform', debug) 43 | options['force'] = ('ffiplatform', True) 44 | options['build_lib'] = ('ffiplatform', tmpdir) 45 | options['build_temp'] = ('ffiplatform', tmpdir) 46 | # 47 | try: 48 | old_level = distutils.log.set_threshold(0) or 0 49 | try: 50 | distutils.log.set_verbosity(compiler_verbose) 51 | dist.run_command('build_ext') 52 | cmd_obj = dist.get_command_obj('build_ext') 53 | [soname] = cmd_obj.get_outputs() 54 | finally: 55 | distutils.log.set_threshold(old_level) 56 | except (distutils.errors.CompileError, 57 | distutils.errors.LinkError) as e: 58 | raise VerificationError('%s: %s' % (e.__class__.__name__, e)) 59 | # 60 | return soname 61 | 62 | try: 63 | from os.path import samefile 64 | except ImportError: 65 | def samefile(f1, f2): 66 | return os.path.abspath(f1) == os.path.abspath(f2) 67 | 68 | def maybe_relative_path(path): 69 | if not os.path.isabs(path): 70 | return path # already relative 71 | dir = path 72 | names = [] 73 | while True: 74 | prevdir = dir 75 | dir, name = os.path.split(prevdir) 76 | if dir == prevdir or not dir: 77 | return path # failed to make it relative 78 | names.append(name) 79 | try: 80 | if samefile(dir, os.curdir): 81 | names.reverse() 82 | return os.path.join(*names) 83 | except OSError: 84 | pass 85 | 86 | # ____________________________________________________________ 87 | 88 | try: 89 | int_or_long = (int, long) 90 | import cStringIO 91 | except NameError: 92 | int_or_long = int # Python 3 93 | import io as cStringIO 94 | 95 | def _flatten(x, f): 96 | if isinstance(x, str): 97 | f.write('%ds%s' % (len(x), x)) 98 | elif isinstance(x, dict): 99 | keys = sorted(x.keys()) 100 | f.write('%dd' % len(keys)) 101 | for key in keys: 102 | _flatten(key, f) 103 | _flatten(x[key], f) 104 | elif isinstance(x, (list, tuple)): 105 | f.write('%dl' % len(x)) 106 | for value in x: 107 | _flatten(value, f) 108 | elif isinstance(x, int_or_long): 109 | f.write('%di' % (x,)) 110 | else: 111 | raise TypeError( 112 | "the keywords to verify() contains unsupported object %r" % (x,)) 113 | 114 | def flatten(x): 115 | f = cStringIO.StringIO() 116 | _flatten(x, f) 117 | return f.getvalue() 118 | 119 | def _hack_at_distutils(): 120 | # Windows-only workaround for some configurations: see 121 | # https://bugs.python.org/issue23246 (Python 2.7 with 122 | # a specific MS compiler suite download) 123 | if sys.platform == "win32": 124 | try: 125 | import setuptools # for side-effects, patches distutils 126 | except ImportError: 127 | pass 128 | -------------------------------------------------------------------------------- /modules/common/dep/cffi37/lock.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info < (3,): 4 | try: 5 | from thread import allocate_lock 6 | except ImportError: 7 | from dummy_thread import allocate_lock 8 | else: 9 | try: 10 | from _thread import allocate_lock 11 | except ImportError: 12 | from _dummy_thread import allocate_lock 13 | 14 | 15 | ##import sys 16 | ##l1 = allocate_lock 17 | 18 | ##class allocate_lock(object): 19 | ## def __init__(self): 20 | ## self._real = l1() 21 | ## def __enter__(self): 22 | ## for i in range(4, 0, -1): 23 | ## print sys._getframe(i).f_code 24 | ## print 25 | ## return self._real.__enter__() 26 | ## def __exit__(self, *args): 27 | ## return self._real.__exit__(*args) 28 | ## def acquire(self, f): 29 | ## assert f is False 30 | ## return self._real.acquire(f) 31 | -------------------------------------------------------------------------------- /modules/common/dep/cffi37/pkgconfig.py: -------------------------------------------------------------------------------- 1 | # pkg-config, https://www.freedesktop.org/wiki/Software/pkg-config/ integration for cffi 2 | import sys, os, subprocess 3 | 4 | from .error import PkgConfigError 5 | 6 | 7 | def merge_flags(cfg1, cfg2): 8 | """Merge values from cffi config flags cfg2 to cf1 9 | 10 | Example: 11 | merge_flags({"libraries": ["one"]}, {"libraries": ["two"]}) 12 | {"libraries": ["one", "two"]} 13 | """ 14 | for key, value in cfg2.items(): 15 | if key not in cfg1: 16 | cfg1[key] = value 17 | else: 18 | if not isinstance(cfg1[key], list): 19 | raise TypeError("cfg1[%r] should be a list of strings" % (key,)) 20 | if not isinstance(value, list): 21 | raise TypeError("cfg2[%r] should be a list of strings" % (key,)) 22 | cfg1[key].extend(value) 23 | return cfg1 24 | 25 | 26 | def call(libname, flag, encoding=sys.getfilesystemencoding()): 27 | """Calls pkg-config and returns the output if found 28 | """ 29 | a = ["pkg-config", "--print-errors"] 30 | a.append(flag) 31 | a.append(libname) 32 | try: 33 | pc = subprocess.Popen(a, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 34 | except EnvironmentError as e: 35 | raise PkgConfigError("cannot run pkg-config: %s" % (str(e).strip(),)) 36 | 37 | bout, berr = pc.communicate() 38 | if pc.returncode != 0: 39 | try: 40 | berr = berr.decode(encoding) 41 | except Exception: 42 | pass 43 | raise PkgConfigError(berr.strip()) 44 | 45 | if sys.version_info >= (3,) and not isinstance(bout, str): # Python 3.x 46 | try: 47 | bout = bout.decode(encoding) 48 | except UnicodeDecodeError: 49 | raise PkgConfigError("pkg-config %s %s returned bytes that cannot " 50 | "be decoded with encoding %r:\n%r" % 51 | (flag, libname, encoding, bout)) 52 | 53 | if os.altsep != '\\' and '\\' in bout: 54 | raise PkgConfigError("pkg-config %s %s returned an unsupported " 55 | "backslash-escaped output:\n%r" % 56 | (flag, libname, bout)) 57 | return bout 58 | 59 | 60 | def flags_from_pkgconfig(libs): 61 | r"""Return compiler line flags for FFI.set_source based on pkg-config output 62 | 63 | Usage 64 | ... 65 | ffibuilder.set_source("_foo", pkgconfig = ["libfoo", "libbar >= 1.8.3"]) 66 | 67 | If pkg-config is installed on build machine, then arguments include_dirs, 68 | library_dirs, libraries, define_macros, extra_compile_args and 69 | extra_link_args are extended with an output of pkg-config for libfoo and 70 | libbar. 71 | 72 | Raises PkgConfigError in case the pkg-config call fails. 73 | """ 74 | 75 | def get_include_dirs(string): 76 | return [x[2:] for x in string.split() if x.startswith("-I")] 77 | 78 | def get_library_dirs(string): 79 | return [x[2:] for x in string.split() if x.startswith("-L")] 80 | 81 | def get_libraries(string): 82 | return [x[2:] for x in string.split() if x.startswith("-l")] 83 | 84 | # convert -Dfoo=bar to list of tuples [("foo", "bar")] expected by distutils 85 | def get_macros(string): 86 | def _macro(x): 87 | x = x[2:] # drop "-D" 88 | if '=' in x: 89 | return tuple(x.split("=", 1)) # "-Dfoo=bar" => ("foo", "bar") 90 | else: 91 | return (x, None) # "-Dfoo" => ("foo", None) 92 | return [_macro(x) for x in string.split() if x.startswith("-D")] 93 | 94 | def get_other_cflags(string): 95 | return [x for x in string.split() if not x.startswith("-I") and 96 | not x.startswith("-D")] 97 | 98 | def get_other_libs(string): 99 | return [x for x in string.split() if not x.startswith("-L") and 100 | not x.startswith("-l")] 101 | 102 | # return kwargs for given libname 103 | def kwargs(libname): 104 | fse = sys.getfilesystemencoding() 105 | all_cflags = call(libname, "--cflags") 106 | all_libs = call(libname, "--libs") 107 | return { 108 | "include_dirs": get_include_dirs(all_cflags), 109 | "library_dirs": get_library_dirs(all_libs), 110 | "libraries": get_libraries(all_libs), 111 | "define_macros": get_macros(all_cflags), 112 | "extra_compile_args": get_other_cflags(all_cflags), 113 | "extra_link_args": get_other_libs(all_libs), 114 | } 115 | 116 | # merge all arguments together 117 | ret = {} 118 | for libname in libs: 119 | lib_flags = kwargs(libname) 120 | merge_flags(ret, lib_flags) 121 | return ret 122 | -------------------------------------------------------------------------------- /modules/common/dep/cffi38/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['FFI', 'VerificationError', 'VerificationMissing', 'CDefError', 2 | 'FFIError'] 3 | 4 | from .api import FFI 5 | from .error import CDefError, FFIError, VerificationError, VerificationMissing 6 | from .error import PkgConfigError 7 | 8 | __version__ = "1.14.5" 9 | __version_info__ = (1, 14, 5) 10 | 11 | # The verifier module file names are based on the CRC32 of a string that 12 | # contains the following version number. It may be older than __version__ 13 | # if nothing is clearly incompatible. 14 | __version_verifier_modules__ = "0.8.6" 15 | -------------------------------------------------------------------------------- /modules/common/dep/cffi38/_cffi_errors.h: -------------------------------------------------------------------------------- 1 | #ifndef CFFI_MESSAGEBOX 2 | # ifdef _MSC_VER 3 | # define CFFI_MESSAGEBOX 1 4 | # else 5 | # define CFFI_MESSAGEBOX 0 6 | # endif 7 | #endif 8 | 9 | 10 | #if CFFI_MESSAGEBOX 11 | /* Windows only: logic to take the Python-CFFI embedding logic 12 | initialization errors and display them in a background thread 13 | with MessageBox. The idea is that if the whole program closes 14 | as a result of this problem, then likely it is already a console 15 | program and you can read the stderr output in the console too. 16 | If it is not a console program, then it will likely show its own 17 | dialog to complain, or generally not abruptly close, and for this 18 | case the background thread should stay alive. 19 | */ 20 | static void *volatile _cffi_bootstrap_text; 21 | 22 | static PyObject *_cffi_start_error_capture(void) 23 | { 24 | PyObject *result = NULL; 25 | PyObject *x, *m, *bi; 26 | 27 | if (InterlockedCompareExchangePointer(&_cffi_bootstrap_text, 28 | (void *)1, NULL) != NULL) 29 | return (PyObject *)1; 30 | 31 | m = PyImport_AddModule("_cffi_error_capture"); 32 | if (m == NULL) 33 | goto error; 34 | 35 | result = PyModule_GetDict(m); 36 | if (result == NULL) 37 | goto error; 38 | 39 | #if PY_MAJOR_VERSION >= 3 40 | bi = PyImport_ImportModule("builtins"); 41 | #else 42 | bi = PyImport_ImportModule("__builtin__"); 43 | #endif 44 | if (bi == NULL) 45 | goto error; 46 | PyDict_SetItemString(result, "__builtins__", bi); 47 | Py_DECREF(bi); 48 | 49 | x = PyRun_String( 50 | "import sys\n" 51 | "class FileLike:\n" 52 | " def write(self, x):\n" 53 | " try:\n" 54 | " of.write(x)\n" 55 | " except: pass\n" 56 | " self.buf += x\n" 57 | "fl = FileLike()\n" 58 | "fl.buf = ''\n" 59 | "of = sys.stderr\n" 60 | "sys.stderr = fl\n" 61 | "def done():\n" 62 | " sys.stderr = of\n" 63 | " return fl.buf\n", /* make sure the returned value stays alive */ 64 | Py_file_input, 65 | result, result); 66 | Py_XDECREF(x); 67 | 68 | error: 69 | if (PyErr_Occurred()) 70 | { 71 | PyErr_WriteUnraisable(Py_None); 72 | PyErr_Clear(); 73 | } 74 | return result; 75 | } 76 | 77 | #pragma comment(lib, "user32.lib") 78 | 79 | static DWORD WINAPI _cffi_bootstrap_dialog(LPVOID ignored) 80 | { 81 | Sleep(666); /* may be interrupted if the whole process is closing */ 82 | #if PY_MAJOR_VERSION >= 3 83 | MessageBoxW(NULL, (wchar_t *)_cffi_bootstrap_text, 84 | L"Python-CFFI error", 85 | MB_OK | MB_ICONERROR); 86 | #else 87 | MessageBoxA(NULL, (char *)_cffi_bootstrap_text, 88 | "Python-CFFI error", 89 | MB_OK | MB_ICONERROR); 90 | #endif 91 | _cffi_bootstrap_text = NULL; 92 | return 0; 93 | } 94 | 95 | static void _cffi_stop_error_capture(PyObject *ecap) 96 | { 97 | PyObject *s; 98 | void *text; 99 | 100 | if (ecap == (PyObject *)1) 101 | return; 102 | 103 | if (ecap == NULL) 104 | goto error; 105 | 106 | s = PyRun_String("done()", Py_eval_input, ecap, ecap); 107 | if (s == NULL) 108 | goto error; 109 | 110 | /* Show a dialog box, but in a background thread, and 111 | never show multiple dialog boxes at once. */ 112 | #if PY_MAJOR_VERSION >= 3 113 | text = PyUnicode_AsWideCharString(s, NULL); 114 | #else 115 | text = PyString_AsString(s); 116 | #endif 117 | 118 | _cffi_bootstrap_text = text; 119 | 120 | if (text != NULL) 121 | { 122 | HANDLE h; 123 | h = CreateThread(NULL, 0, _cffi_bootstrap_dialog, 124 | NULL, 0, NULL); 125 | if (h != NULL) 126 | CloseHandle(h); 127 | } 128 | /* decref the string, but it should stay alive as 'fl.buf' 129 | in the small module above. It will really be freed only if 130 | we later get another similar error. So it's a leak of at 131 | most one copy of the small module. That's fine for this 132 | situation which is usually a "fatal error" anyway. */ 133 | Py_DECREF(s); 134 | PyErr_Clear(); 135 | return; 136 | 137 | error: 138 | _cffi_bootstrap_text = NULL; 139 | PyErr_Clear(); 140 | } 141 | 142 | #else 143 | 144 | static PyObject *_cffi_start_error_capture(void) { return NULL; } 145 | static void _cffi_stop_error_capture(PyObject *ecap) { } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /modules/common/dep/cffi38/commontypes.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from . import model 3 | from .error import FFIError 4 | 5 | 6 | COMMON_TYPES = {} 7 | 8 | try: 9 | # fetch "bool" and all simple Windows types 10 | from _cffi_backend import _get_common_types 11 | _get_common_types(COMMON_TYPES) 12 | except ImportError: 13 | pass 14 | 15 | COMMON_TYPES['FILE'] = model.unknown_type('FILE', '_IO_FILE') 16 | COMMON_TYPES['bool'] = '_Bool' # in case we got ImportError above 17 | 18 | for _type in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 19 | if _type.endswith('_t'): 20 | COMMON_TYPES[_type] = _type 21 | del _type 22 | 23 | _CACHE = {} 24 | 25 | def resolve_common_type(parser, commontype): 26 | try: 27 | return _CACHE[commontype] 28 | except KeyError: 29 | cdecl = COMMON_TYPES.get(commontype, commontype) 30 | if not isinstance(cdecl, str): 31 | result, quals = cdecl, 0 # cdecl is already a BaseType 32 | elif cdecl in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 33 | result, quals = model.PrimitiveType(cdecl), 0 34 | elif cdecl == 'set-unicode-needed': 35 | raise FFIError("The Windows type %r is only available after " 36 | "you call ffi.set_unicode()" % (commontype,)) 37 | else: 38 | if commontype == cdecl: 39 | raise FFIError( 40 | "Unsupported type: %r. Please look at " 41 | "http://cffi.readthedocs.io/en/latest/cdef.html#ffi-cdef-limitations " 42 | "and file an issue if you think this type should really " 43 | "be supported." % (commontype,)) 44 | result, quals = parser.parse_type_and_quals(cdecl) # recursive 45 | 46 | assert isinstance(result, model.BaseTypeByIdentity) 47 | _CACHE[commontype] = result, quals 48 | return result, quals 49 | 50 | 51 | # ____________________________________________________________ 52 | # extra types for Windows (most of them are in commontypes.c) 53 | 54 | 55 | def win_common_types(): 56 | return { 57 | "UNICODE_STRING": model.StructType( 58 | "_UNICODE_STRING", 59 | ["Length", 60 | "MaximumLength", 61 | "Buffer"], 62 | [model.PrimitiveType("unsigned short"), 63 | model.PrimitiveType("unsigned short"), 64 | model.PointerType(model.PrimitiveType("wchar_t"))], 65 | [-1, -1, -1]), 66 | "PUNICODE_STRING": "UNICODE_STRING *", 67 | "PCUNICODE_STRING": "const UNICODE_STRING *", 68 | 69 | "TBYTE": "set-unicode-needed", 70 | "TCHAR": "set-unicode-needed", 71 | "LPCTSTR": "set-unicode-needed", 72 | "PCTSTR": "set-unicode-needed", 73 | "LPTSTR": "set-unicode-needed", 74 | "PTSTR": "set-unicode-needed", 75 | "PTBYTE": "set-unicode-needed", 76 | "PTCHAR": "set-unicode-needed", 77 | } 78 | 79 | if sys.platform == 'win32': 80 | COMMON_TYPES.update(win_common_types()) 81 | -------------------------------------------------------------------------------- /modules/common/dep/cffi38/error.py: -------------------------------------------------------------------------------- 1 | 2 | class FFIError(Exception): 3 | __module__ = 'cffi' 4 | 5 | class CDefError(Exception): 6 | __module__ = 'cffi' 7 | def __str__(self): 8 | try: 9 | current_decl = self.args[1] 10 | filename = current_decl.coord.file 11 | linenum = current_decl.coord.line 12 | prefix = '%s:%d: ' % (filename, linenum) 13 | except (AttributeError, TypeError, IndexError): 14 | prefix = '' 15 | return '%s%s' % (prefix, self.args[0]) 16 | 17 | class VerificationError(Exception): 18 | """ An error raised when verification fails 19 | """ 20 | __module__ = 'cffi' 21 | 22 | class VerificationMissing(Exception): 23 | """ An error raised when incomplete structures are passed into 24 | cdef, but no verification has been done 25 | """ 26 | __module__ = 'cffi' 27 | 28 | class PkgConfigError(Exception): 29 | """ An error raised for missing modules in pkg-config 30 | """ 31 | __module__ = 'cffi' 32 | -------------------------------------------------------------------------------- /modules/common/dep/cffi38/ffiplatform.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | from .error import VerificationError 3 | 4 | 5 | LIST_OF_FILE_NAMES = ['sources', 'include_dirs', 'library_dirs', 6 | 'extra_objects', 'depends'] 7 | 8 | def get_extension(srcfilename, modname, sources=(), **kwds): 9 | _hack_at_distutils() 10 | from distutils.core import Extension 11 | allsources = [srcfilename] 12 | for src in sources: 13 | allsources.append(os.path.normpath(src)) 14 | return Extension(name=modname, sources=allsources, **kwds) 15 | 16 | def compile(tmpdir, ext, compiler_verbose=0, debug=None): 17 | """Compile a C extension module using distutils.""" 18 | 19 | _hack_at_distutils() 20 | saved_environ = os.environ.copy() 21 | try: 22 | outputfilename = _build(tmpdir, ext, compiler_verbose, debug) 23 | outputfilename = os.path.abspath(outputfilename) 24 | finally: 25 | # workaround for a distutils bugs where some env vars can 26 | # become longer and longer every time it is used 27 | for key, value in saved_environ.items(): 28 | if os.environ.get(key) != value: 29 | os.environ[key] = value 30 | return outputfilename 31 | 32 | def _build(tmpdir, ext, compiler_verbose=0, debug=None): 33 | # XXX compact but horrible :-( 34 | from distutils.core import Distribution 35 | import distutils.errors, distutils.log 36 | # 37 | dist = Distribution({'ext_modules': [ext]}) 38 | dist.parse_config_files() 39 | options = dist.get_option_dict('build_ext') 40 | if debug is None: 41 | debug = sys.flags.debug 42 | options['debug'] = ('ffiplatform', debug) 43 | options['force'] = ('ffiplatform', True) 44 | options['build_lib'] = ('ffiplatform', tmpdir) 45 | options['build_temp'] = ('ffiplatform', tmpdir) 46 | # 47 | try: 48 | old_level = distutils.log.set_threshold(0) or 0 49 | try: 50 | distutils.log.set_verbosity(compiler_verbose) 51 | dist.run_command('build_ext') 52 | cmd_obj = dist.get_command_obj('build_ext') 53 | [soname] = cmd_obj.get_outputs() 54 | finally: 55 | distutils.log.set_threshold(old_level) 56 | except (distutils.errors.CompileError, 57 | distutils.errors.LinkError) as e: 58 | raise VerificationError('%s: %s' % (e.__class__.__name__, e)) 59 | # 60 | return soname 61 | 62 | try: 63 | from os.path import samefile 64 | except ImportError: 65 | def samefile(f1, f2): 66 | return os.path.abspath(f1) == os.path.abspath(f2) 67 | 68 | def maybe_relative_path(path): 69 | if not os.path.isabs(path): 70 | return path # already relative 71 | dir = path 72 | names = [] 73 | while True: 74 | prevdir = dir 75 | dir, name = os.path.split(prevdir) 76 | if dir == prevdir or not dir: 77 | return path # failed to make it relative 78 | names.append(name) 79 | try: 80 | if samefile(dir, os.curdir): 81 | names.reverse() 82 | return os.path.join(*names) 83 | except OSError: 84 | pass 85 | 86 | # ____________________________________________________________ 87 | 88 | try: 89 | int_or_long = (int, long) 90 | import cStringIO 91 | except NameError: 92 | int_or_long = int # Python 3 93 | import io as cStringIO 94 | 95 | def _flatten(x, f): 96 | if isinstance(x, str): 97 | f.write('%ds%s' % (len(x), x)) 98 | elif isinstance(x, dict): 99 | keys = sorted(x.keys()) 100 | f.write('%dd' % len(keys)) 101 | for key in keys: 102 | _flatten(key, f) 103 | _flatten(x[key], f) 104 | elif isinstance(x, (list, tuple)): 105 | f.write('%dl' % len(x)) 106 | for value in x: 107 | _flatten(value, f) 108 | elif isinstance(x, int_or_long): 109 | f.write('%di' % (x,)) 110 | else: 111 | raise TypeError( 112 | "the keywords to verify() contains unsupported object %r" % (x,)) 113 | 114 | def flatten(x): 115 | f = cStringIO.StringIO() 116 | _flatten(x, f) 117 | return f.getvalue() 118 | 119 | def _hack_at_distutils(): 120 | # Windows-only workaround for some configurations: see 121 | # https://bugs.python.org/issue23246 (Python 2.7 with 122 | # a specific MS compiler suite download) 123 | if sys.platform == "win32": 124 | try: 125 | import setuptools # for side-effects, patches distutils 126 | except ImportError: 127 | pass 128 | -------------------------------------------------------------------------------- /modules/common/dep/cffi38/lock.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info < (3,): 4 | try: 5 | from thread import allocate_lock 6 | except ImportError: 7 | from dummy_thread import allocate_lock 8 | else: 9 | try: 10 | from _thread import allocate_lock 11 | except ImportError: 12 | from _dummy_thread import allocate_lock 13 | 14 | 15 | ##import sys 16 | ##l1 = allocate_lock 17 | 18 | ##class allocate_lock(object): 19 | ## def __init__(self): 20 | ## self._real = l1() 21 | ## def __enter__(self): 22 | ## for i in range(4, 0, -1): 23 | ## print sys._getframe(i).f_code 24 | ## print 25 | ## return self._real.__enter__() 26 | ## def __exit__(self, *args): 27 | ## return self._real.__exit__(*args) 28 | ## def acquire(self, f): 29 | ## assert f is False 30 | ## return self._real.acquire(f) 31 | -------------------------------------------------------------------------------- /modules/common/dep/cffi38/pkgconfig.py: -------------------------------------------------------------------------------- 1 | # pkg-config, https://www.freedesktop.org/wiki/Software/pkg-config/ integration for cffi 2 | import sys, os, subprocess 3 | 4 | from .error import PkgConfigError 5 | 6 | 7 | def merge_flags(cfg1, cfg2): 8 | """Merge values from cffi config flags cfg2 to cf1 9 | 10 | Example: 11 | merge_flags({"libraries": ["one"]}, {"libraries": ["two"]}) 12 | {"libraries": ["one", "two"]} 13 | """ 14 | for key, value in cfg2.items(): 15 | if key not in cfg1: 16 | cfg1[key] = value 17 | else: 18 | if not isinstance(cfg1[key], list): 19 | raise TypeError("cfg1[%r] should be a list of strings" % (key,)) 20 | if not isinstance(value, list): 21 | raise TypeError("cfg2[%r] should be a list of strings" % (key,)) 22 | cfg1[key].extend(value) 23 | return cfg1 24 | 25 | 26 | def call(libname, flag, encoding=sys.getfilesystemencoding()): 27 | """Calls pkg-config and returns the output if found 28 | """ 29 | a = ["pkg-config", "--print-errors"] 30 | a.append(flag) 31 | a.append(libname) 32 | try: 33 | pc = subprocess.Popen(a, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 34 | except EnvironmentError as e: 35 | raise PkgConfigError("cannot run pkg-config: %s" % (str(e).strip(),)) 36 | 37 | bout, berr = pc.communicate() 38 | if pc.returncode != 0: 39 | try: 40 | berr = berr.decode(encoding) 41 | except Exception: 42 | pass 43 | raise PkgConfigError(berr.strip()) 44 | 45 | if sys.version_info >= (3,) and not isinstance(bout, str): # Python 3.x 46 | try: 47 | bout = bout.decode(encoding) 48 | except UnicodeDecodeError: 49 | raise PkgConfigError("pkg-config %s %s returned bytes that cannot " 50 | "be decoded with encoding %r:\n%r" % 51 | (flag, libname, encoding, bout)) 52 | 53 | if os.altsep != '\\' and '\\' in bout: 54 | raise PkgConfigError("pkg-config %s %s returned an unsupported " 55 | "backslash-escaped output:\n%r" % 56 | (flag, libname, bout)) 57 | return bout 58 | 59 | 60 | def flags_from_pkgconfig(libs): 61 | r"""Return compiler line flags for FFI.set_source based on pkg-config output 62 | 63 | Usage 64 | ... 65 | ffibuilder.set_source("_foo", pkgconfig = ["libfoo", "libbar >= 1.8.3"]) 66 | 67 | If pkg-config is installed on build machine, then arguments include_dirs, 68 | library_dirs, libraries, define_macros, extra_compile_args and 69 | extra_link_args are extended with an output of pkg-config for libfoo and 70 | libbar. 71 | 72 | Raises PkgConfigError in case the pkg-config call fails. 73 | """ 74 | 75 | def get_include_dirs(string): 76 | return [x[2:] for x in string.split() if x.startswith("-I")] 77 | 78 | def get_library_dirs(string): 79 | return [x[2:] for x in string.split() if x.startswith("-L")] 80 | 81 | def get_libraries(string): 82 | return [x[2:] for x in string.split() if x.startswith("-l")] 83 | 84 | # convert -Dfoo=bar to list of tuples [("foo", "bar")] expected by distutils 85 | def get_macros(string): 86 | def _macro(x): 87 | x = x[2:] # drop "-D" 88 | if '=' in x: 89 | return tuple(x.split("=", 1)) # "-Dfoo=bar" => ("foo", "bar") 90 | else: 91 | return (x, None) # "-Dfoo" => ("foo", None) 92 | return [_macro(x) for x in string.split() if x.startswith("-D")] 93 | 94 | def get_other_cflags(string): 95 | return [x for x in string.split() if not x.startswith("-I") and 96 | not x.startswith("-D")] 97 | 98 | def get_other_libs(string): 99 | return [x for x in string.split() if not x.startswith("-L") and 100 | not x.startswith("-l")] 101 | 102 | # return kwargs for given libname 103 | def kwargs(libname): 104 | fse = sys.getfilesystemencoding() 105 | all_cflags = call(libname, "--cflags") 106 | all_libs = call(libname, "--libs") 107 | return { 108 | "include_dirs": get_include_dirs(all_cflags), 109 | "library_dirs": get_library_dirs(all_libs), 110 | "libraries": get_libraries(all_libs), 111 | "define_macros": get_macros(all_cflags), 112 | "extra_compile_args": get_other_cflags(all_cflags), 113 | "extra_link_args": get_other_libs(all_libs), 114 | } 115 | 116 | # merge all arguments together 117 | ret = {} 118 | for libname in libs: 119 | lib_flags = kwargs(libname) 120 | merge_flags(ret, lib_flags) 121 | return ret 122 | -------------------------------------------------------------------------------- /modules/common/dep/cffi39/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['FFI', 'VerificationError', 'VerificationMissing', 'CDefError', 2 | 'FFIError'] 3 | 4 | from .api import FFI 5 | from .error import CDefError, FFIError, VerificationError, VerificationMissing 6 | from .error import PkgConfigError 7 | 8 | __version__ = "1.14.5" 9 | __version_info__ = (1, 14, 5) 10 | 11 | # The verifier module file names are based on the CRC32 of a string that 12 | # contains the following version number. It may be older than __version__ 13 | # if nothing is clearly incompatible. 14 | __version_verifier_modules__ = "0.8.6" 15 | -------------------------------------------------------------------------------- /modules/common/dep/cffi39/_cffi_errors.h: -------------------------------------------------------------------------------- 1 | #ifndef CFFI_MESSAGEBOX 2 | # ifdef _MSC_VER 3 | # define CFFI_MESSAGEBOX 1 4 | # else 5 | # define CFFI_MESSAGEBOX 0 6 | # endif 7 | #endif 8 | 9 | 10 | #if CFFI_MESSAGEBOX 11 | /* Windows only: logic to take the Python-CFFI embedding logic 12 | initialization errors and display them in a background thread 13 | with MessageBox. The idea is that if the whole program closes 14 | as a result of this problem, then likely it is already a console 15 | program and you can read the stderr output in the console too. 16 | If it is not a console program, then it will likely show its own 17 | dialog to complain, or generally not abruptly close, and for this 18 | case the background thread should stay alive. 19 | */ 20 | static void *volatile _cffi_bootstrap_text; 21 | 22 | static PyObject *_cffi_start_error_capture(void) 23 | { 24 | PyObject *result = NULL; 25 | PyObject *x, *m, *bi; 26 | 27 | if (InterlockedCompareExchangePointer(&_cffi_bootstrap_text, 28 | (void *)1, NULL) != NULL) 29 | return (PyObject *)1; 30 | 31 | m = PyImport_AddModule("_cffi_error_capture"); 32 | if (m == NULL) 33 | goto error; 34 | 35 | result = PyModule_GetDict(m); 36 | if (result == NULL) 37 | goto error; 38 | 39 | #if PY_MAJOR_VERSION >= 3 40 | bi = PyImport_ImportModule("builtins"); 41 | #else 42 | bi = PyImport_ImportModule("__builtin__"); 43 | #endif 44 | if (bi == NULL) 45 | goto error; 46 | PyDict_SetItemString(result, "__builtins__", bi); 47 | Py_DECREF(bi); 48 | 49 | x = PyRun_String( 50 | "import sys\n" 51 | "class FileLike:\n" 52 | " def write(self, x):\n" 53 | " try:\n" 54 | " of.write(x)\n" 55 | " except: pass\n" 56 | " self.buf += x\n" 57 | "fl = FileLike()\n" 58 | "fl.buf = ''\n" 59 | "of = sys.stderr\n" 60 | "sys.stderr = fl\n" 61 | "def done():\n" 62 | " sys.stderr = of\n" 63 | " return fl.buf\n", /* make sure the returned value stays alive */ 64 | Py_file_input, 65 | result, result); 66 | Py_XDECREF(x); 67 | 68 | error: 69 | if (PyErr_Occurred()) 70 | { 71 | PyErr_WriteUnraisable(Py_None); 72 | PyErr_Clear(); 73 | } 74 | return result; 75 | } 76 | 77 | #pragma comment(lib, "user32.lib") 78 | 79 | static DWORD WINAPI _cffi_bootstrap_dialog(LPVOID ignored) 80 | { 81 | Sleep(666); /* may be interrupted if the whole process is closing */ 82 | #if PY_MAJOR_VERSION >= 3 83 | MessageBoxW(NULL, (wchar_t *)_cffi_bootstrap_text, 84 | L"Python-CFFI error", 85 | MB_OK | MB_ICONERROR); 86 | #else 87 | MessageBoxA(NULL, (char *)_cffi_bootstrap_text, 88 | "Python-CFFI error", 89 | MB_OK | MB_ICONERROR); 90 | #endif 91 | _cffi_bootstrap_text = NULL; 92 | return 0; 93 | } 94 | 95 | static void _cffi_stop_error_capture(PyObject *ecap) 96 | { 97 | PyObject *s; 98 | void *text; 99 | 100 | if (ecap == (PyObject *)1) 101 | return; 102 | 103 | if (ecap == NULL) 104 | goto error; 105 | 106 | s = PyRun_String("done()", Py_eval_input, ecap, ecap); 107 | if (s == NULL) 108 | goto error; 109 | 110 | /* Show a dialog box, but in a background thread, and 111 | never show multiple dialog boxes at once. */ 112 | #if PY_MAJOR_VERSION >= 3 113 | text = PyUnicode_AsWideCharString(s, NULL); 114 | #else 115 | text = PyString_AsString(s); 116 | #endif 117 | 118 | _cffi_bootstrap_text = text; 119 | 120 | if (text != NULL) 121 | { 122 | HANDLE h; 123 | h = CreateThread(NULL, 0, _cffi_bootstrap_dialog, 124 | NULL, 0, NULL); 125 | if (h != NULL) 126 | CloseHandle(h); 127 | } 128 | /* decref the string, but it should stay alive as 'fl.buf' 129 | in the small module above. It will really be freed only if 130 | we later get another similar error. So it's a leak of at 131 | most one copy of the small module. That's fine for this 132 | situation which is usually a "fatal error" anyway. */ 133 | Py_DECREF(s); 134 | PyErr_Clear(); 135 | return; 136 | 137 | error: 138 | _cffi_bootstrap_text = NULL; 139 | PyErr_Clear(); 140 | } 141 | 142 | #else 143 | 144 | static PyObject *_cffi_start_error_capture(void) { return NULL; } 145 | static void _cffi_stop_error_capture(PyObject *ecap) { } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /modules/common/dep/cffi39/commontypes.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from . import model 3 | from .error import FFIError 4 | 5 | 6 | COMMON_TYPES = {} 7 | 8 | try: 9 | # fetch "bool" and all simple Windows types 10 | from _cffi_backend import _get_common_types 11 | _get_common_types(COMMON_TYPES) 12 | except ImportError: 13 | pass 14 | 15 | COMMON_TYPES['FILE'] = model.unknown_type('FILE', '_IO_FILE') 16 | COMMON_TYPES['bool'] = '_Bool' # in case we got ImportError above 17 | 18 | for _type in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 19 | if _type.endswith('_t'): 20 | COMMON_TYPES[_type] = _type 21 | del _type 22 | 23 | _CACHE = {} 24 | 25 | def resolve_common_type(parser, commontype): 26 | try: 27 | return _CACHE[commontype] 28 | except KeyError: 29 | cdecl = COMMON_TYPES.get(commontype, commontype) 30 | if not isinstance(cdecl, str): 31 | result, quals = cdecl, 0 # cdecl is already a BaseType 32 | elif cdecl in model.PrimitiveType.ALL_PRIMITIVE_TYPES: 33 | result, quals = model.PrimitiveType(cdecl), 0 34 | elif cdecl == 'set-unicode-needed': 35 | raise FFIError("The Windows type %r is only available after " 36 | "you call ffi.set_unicode()" % (commontype,)) 37 | else: 38 | if commontype == cdecl: 39 | raise FFIError( 40 | "Unsupported type: %r. Please look at " 41 | "http://cffi.readthedocs.io/en/latest/cdef.html#ffi-cdef-limitations " 42 | "and file an issue if you think this type should really " 43 | "be supported." % (commontype,)) 44 | result, quals = parser.parse_type_and_quals(cdecl) # recursive 45 | 46 | assert isinstance(result, model.BaseTypeByIdentity) 47 | _CACHE[commontype] = result, quals 48 | return result, quals 49 | 50 | 51 | # ____________________________________________________________ 52 | # extra types for Windows (most of them are in commontypes.c) 53 | 54 | 55 | def win_common_types(): 56 | return { 57 | "UNICODE_STRING": model.StructType( 58 | "_UNICODE_STRING", 59 | ["Length", 60 | "MaximumLength", 61 | "Buffer"], 62 | [model.PrimitiveType("unsigned short"), 63 | model.PrimitiveType("unsigned short"), 64 | model.PointerType(model.PrimitiveType("wchar_t"))], 65 | [-1, -1, -1]), 66 | "PUNICODE_STRING": "UNICODE_STRING *", 67 | "PCUNICODE_STRING": "const UNICODE_STRING *", 68 | 69 | "TBYTE": "set-unicode-needed", 70 | "TCHAR": "set-unicode-needed", 71 | "LPCTSTR": "set-unicode-needed", 72 | "PCTSTR": "set-unicode-needed", 73 | "LPTSTR": "set-unicode-needed", 74 | "PTSTR": "set-unicode-needed", 75 | "PTBYTE": "set-unicode-needed", 76 | "PTCHAR": "set-unicode-needed", 77 | } 78 | 79 | if sys.platform == 'win32': 80 | COMMON_TYPES.update(win_common_types()) 81 | -------------------------------------------------------------------------------- /modules/common/dep/cffi39/error.py: -------------------------------------------------------------------------------- 1 | 2 | class FFIError(Exception): 3 | __module__ = 'cffi' 4 | 5 | class CDefError(Exception): 6 | __module__ = 'cffi' 7 | def __str__(self): 8 | try: 9 | current_decl = self.args[1] 10 | filename = current_decl.coord.file 11 | linenum = current_decl.coord.line 12 | prefix = '%s:%d: ' % (filename, linenum) 13 | except (AttributeError, TypeError, IndexError): 14 | prefix = '' 15 | return '%s%s' % (prefix, self.args[0]) 16 | 17 | class VerificationError(Exception): 18 | """ An error raised when verification fails 19 | """ 20 | __module__ = 'cffi' 21 | 22 | class VerificationMissing(Exception): 23 | """ An error raised when incomplete structures are passed into 24 | cdef, but no verification has been done 25 | """ 26 | __module__ = 'cffi' 27 | 28 | class PkgConfigError(Exception): 29 | """ An error raised for missing modules in pkg-config 30 | """ 31 | __module__ = 'cffi' 32 | -------------------------------------------------------------------------------- /modules/common/dep/cffi39/ffiplatform.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | from .error import VerificationError 3 | 4 | 5 | LIST_OF_FILE_NAMES = ['sources', 'include_dirs', 'library_dirs', 6 | 'extra_objects', 'depends'] 7 | 8 | def get_extension(srcfilename, modname, sources=(), **kwds): 9 | _hack_at_distutils() 10 | from distutils.core import Extension 11 | allsources = [srcfilename] 12 | for src in sources: 13 | allsources.append(os.path.normpath(src)) 14 | return Extension(name=modname, sources=allsources, **kwds) 15 | 16 | def compile(tmpdir, ext, compiler_verbose=0, debug=None): 17 | """Compile a C extension module using distutils.""" 18 | 19 | _hack_at_distutils() 20 | saved_environ = os.environ.copy() 21 | try: 22 | outputfilename = _build(tmpdir, ext, compiler_verbose, debug) 23 | outputfilename = os.path.abspath(outputfilename) 24 | finally: 25 | # workaround for a distutils bugs where some env vars can 26 | # become longer and longer every time it is used 27 | for key, value in saved_environ.items(): 28 | if os.environ.get(key) != value: 29 | os.environ[key] = value 30 | return outputfilename 31 | 32 | def _build(tmpdir, ext, compiler_verbose=0, debug=None): 33 | # XXX compact but horrible :-( 34 | from distutils.core import Distribution 35 | import distutils.errors, distutils.log 36 | # 37 | dist = Distribution({'ext_modules': [ext]}) 38 | dist.parse_config_files() 39 | options = dist.get_option_dict('build_ext') 40 | if debug is None: 41 | debug = sys.flags.debug 42 | options['debug'] = ('ffiplatform', debug) 43 | options['force'] = ('ffiplatform', True) 44 | options['build_lib'] = ('ffiplatform', tmpdir) 45 | options['build_temp'] = ('ffiplatform', tmpdir) 46 | # 47 | try: 48 | old_level = distutils.log.set_threshold(0) or 0 49 | try: 50 | distutils.log.set_verbosity(compiler_verbose) 51 | dist.run_command('build_ext') 52 | cmd_obj = dist.get_command_obj('build_ext') 53 | [soname] = cmd_obj.get_outputs() 54 | finally: 55 | distutils.log.set_threshold(old_level) 56 | except (distutils.errors.CompileError, 57 | distutils.errors.LinkError) as e: 58 | raise VerificationError('%s: %s' % (e.__class__.__name__, e)) 59 | # 60 | return soname 61 | 62 | try: 63 | from os.path import samefile 64 | except ImportError: 65 | def samefile(f1, f2): 66 | return os.path.abspath(f1) == os.path.abspath(f2) 67 | 68 | def maybe_relative_path(path): 69 | if not os.path.isabs(path): 70 | return path # already relative 71 | dir = path 72 | names = [] 73 | while True: 74 | prevdir = dir 75 | dir, name = os.path.split(prevdir) 76 | if dir == prevdir or not dir: 77 | return path # failed to make it relative 78 | names.append(name) 79 | try: 80 | if samefile(dir, os.curdir): 81 | names.reverse() 82 | return os.path.join(*names) 83 | except OSError: 84 | pass 85 | 86 | # ____________________________________________________________ 87 | 88 | try: 89 | int_or_long = (int, long) 90 | import cStringIO 91 | except NameError: 92 | int_or_long = int # Python 3 93 | import io as cStringIO 94 | 95 | def _flatten(x, f): 96 | if isinstance(x, str): 97 | f.write('%ds%s' % (len(x), x)) 98 | elif isinstance(x, dict): 99 | keys = sorted(x.keys()) 100 | f.write('%dd' % len(keys)) 101 | for key in keys: 102 | _flatten(key, f) 103 | _flatten(x[key], f) 104 | elif isinstance(x, (list, tuple)): 105 | f.write('%dl' % len(x)) 106 | for value in x: 107 | _flatten(value, f) 108 | elif isinstance(x, int_or_long): 109 | f.write('%di' % (x,)) 110 | else: 111 | raise TypeError( 112 | "the keywords to verify() contains unsupported object %r" % (x,)) 113 | 114 | def flatten(x): 115 | f = cStringIO.StringIO() 116 | _flatten(x, f) 117 | return f.getvalue() 118 | 119 | def _hack_at_distutils(): 120 | # Windows-only workaround for some configurations: see 121 | # https://bugs.python.org/issue23246 (Python 2.7 with 122 | # a specific MS compiler suite download) 123 | if sys.platform == "win32": 124 | try: 125 | import setuptools # for side-effects, patches distutils 126 | except ImportError: 127 | pass 128 | -------------------------------------------------------------------------------- /modules/common/dep/cffi39/lock.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | if sys.version_info < (3,): 4 | try: 5 | from thread import allocate_lock 6 | except ImportError: 7 | from dummy_thread import allocate_lock 8 | else: 9 | try: 10 | from _thread import allocate_lock 11 | except ImportError: 12 | from _dummy_thread import allocate_lock 13 | 14 | 15 | ##import sys 16 | ##l1 = allocate_lock 17 | 18 | ##class allocate_lock(object): 19 | ## def __init__(self): 20 | ## self._real = l1() 21 | ## def __enter__(self): 22 | ## for i in range(4, 0, -1): 23 | ## print sys._getframe(i).f_code 24 | ## print 25 | ## return self._real.__enter__() 26 | ## def __exit__(self, *args): 27 | ## return self._real.__exit__(*args) 28 | ## def acquire(self, f): 29 | ## assert f is False 30 | ## return self._real.acquire(f) 31 | -------------------------------------------------------------------------------- /modules/common/dep/cffi39/pkgconfig.py: -------------------------------------------------------------------------------- 1 | # pkg-config, https://www.freedesktop.org/wiki/Software/pkg-config/ integration for cffi 2 | import sys, os, subprocess 3 | 4 | from .error import PkgConfigError 5 | 6 | 7 | def merge_flags(cfg1, cfg2): 8 | """Merge values from cffi config flags cfg2 to cf1 9 | 10 | Example: 11 | merge_flags({"libraries": ["one"]}, {"libraries": ["two"]}) 12 | {"libraries": ["one", "two"]} 13 | """ 14 | for key, value in cfg2.items(): 15 | if key not in cfg1: 16 | cfg1[key] = value 17 | else: 18 | if not isinstance(cfg1[key], list): 19 | raise TypeError("cfg1[%r] should be a list of strings" % (key,)) 20 | if not isinstance(value, list): 21 | raise TypeError("cfg2[%r] should be a list of strings" % (key,)) 22 | cfg1[key].extend(value) 23 | return cfg1 24 | 25 | 26 | def call(libname, flag, encoding=sys.getfilesystemencoding()): 27 | """Calls pkg-config and returns the output if found 28 | """ 29 | a = ["pkg-config", "--print-errors"] 30 | a.append(flag) 31 | a.append(libname) 32 | try: 33 | pc = subprocess.Popen(a, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 34 | except EnvironmentError as e: 35 | raise PkgConfigError("cannot run pkg-config: %s" % (str(e).strip(),)) 36 | 37 | bout, berr = pc.communicate() 38 | if pc.returncode != 0: 39 | try: 40 | berr = berr.decode(encoding) 41 | except Exception: 42 | pass 43 | raise PkgConfigError(berr.strip()) 44 | 45 | if sys.version_info >= (3,) and not isinstance(bout, str): # Python 3.x 46 | try: 47 | bout = bout.decode(encoding) 48 | except UnicodeDecodeError: 49 | raise PkgConfigError("pkg-config %s %s returned bytes that cannot " 50 | "be decoded with encoding %r:\n%r" % 51 | (flag, libname, encoding, bout)) 52 | 53 | if os.altsep != '\\' and '\\' in bout: 54 | raise PkgConfigError("pkg-config %s %s returned an unsupported " 55 | "backslash-escaped output:\n%r" % 56 | (flag, libname, bout)) 57 | return bout 58 | 59 | 60 | def flags_from_pkgconfig(libs): 61 | r"""Return compiler line flags for FFI.set_source based on pkg-config output 62 | 63 | Usage 64 | ... 65 | ffibuilder.set_source("_foo", pkgconfig = ["libfoo", "libbar >= 1.8.3"]) 66 | 67 | If pkg-config is installed on build machine, then arguments include_dirs, 68 | library_dirs, libraries, define_macros, extra_compile_args and 69 | extra_link_args are extended with an output of pkg-config for libfoo and 70 | libbar. 71 | 72 | Raises PkgConfigError in case the pkg-config call fails. 73 | """ 74 | 75 | def get_include_dirs(string): 76 | return [x[2:] for x in string.split() if x.startswith("-I")] 77 | 78 | def get_library_dirs(string): 79 | return [x[2:] for x in string.split() if x.startswith("-L")] 80 | 81 | def get_libraries(string): 82 | return [x[2:] for x in string.split() if x.startswith("-l")] 83 | 84 | # convert -Dfoo=bar to list of tuples [("foo", "bar")] expected by distutils 85 | def get_macros(string): 86 | def _macro(x): 87 | x = x[2:] # drop "-D" 88 | if '=' in x: 89 | return tuple(x.split("=", 1)) # "-Dfoo=bar" => ("foo", "bar") 90 | else: 91 | return (x, None) # "-Dfoo" => ("foo", None) 92 | return [_macro(x) for x in string.split() if x.startswith("-D")] 93 | 94 | def get_other_cflags(string): 95 | return [x for x in string.split() if not x.startswith("-I") and 96 | not x.startswith("-D")] 97 | 98 | def get_other_libs(string): 99 | return [x for x in string.split() if not x.startswith("-L") and 100 | not x.startswith("-l")] 101 | 102 | # return kwargs for given libname 103 | def kwargs(libname): 104 | fse = sys.getfilesystemencoding() 105 | all_cflags = call(libname, "--cflags") 106 | all_libs = call(libname, "--libs") 107 | return { 108 | "include_dirs": get_include_dirs(all_cflags), 109 | "library_dirs": get_library_dirs(all_libs), 110 | "libraries": get_libraries(all_libs), 111 | "define_macros": get_macros(all_cflags), 112 | "extra_compile_args": get_other_cflags(all_cflags), 113 | "extra_link_args": get_other_libs(all_libs), 114 | } 115 | 116 | # merge all arguments together 117 | ret = {} 118 | for libname in libs: 119 | lib_flags = kwargs(libname) 120 | merge_flags(ret, lib_flags) 121 | return ret 122 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser-2.20.dist-info/INSTALLER: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser-2.20.dist-info/LICENSE: -------------------------------------------------------------------------------- 1 | pycparser -- A C parser in Python 2 | 3 | Copyright (c) 2008-2017, Eli Bendersky 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without modification, 7 | are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | * Neither the name of Eli Bendersky nor the names of its contributors may 15 | be used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 24 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 27 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser-2.20.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: pycparser 3 | Version: 2.20 4 | Summary: C parser in Python 5 | Home-page: https://github.com/eliben/pycparser 6 | Author: Eli Bendersky 7 | Author-email: eliben@gmail.com 8 | Maintainer: Eli Bendersky 9 | License: BSD 10 | Platform: Cross Platform 11 | Classifier: Development Status :: 5 - Production/Stable 12 | Classifier: License :: OSI Approved :: BSD License 13 | Classifier: Programming Language :: Python :: 2 14 | Classifier: Programming Language :: Python :: 2.7 15 | Classifier: Programming Language :: Python :: 3 16 | Classifier: Programming Language :: Python :: 3.4 17 | Classifier: Programming Language :: Python :: 3.5 18 | Classifier: Programming Language :: Python :: 3.6 19 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* 20 | 21 | 22 | pycparser is a complete parser of the C language, written in 23 | pure Python using the PLY parsing library. 24 | It parses C code into an AST and can serve as a front-end for 25 | C compilers or analysis tools. 26 | 27 | 28 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser-2.20.dist-info/RECORD: -------------------------------------------------------------------------------- 1 | pycparser-2.20.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 2 | pycparser-2.20.dist-info/LICENSE,sha256=PHZimICuwvhXjtkUcBpP-eXai2CsuLfsZ1q_g8kMUWg,1536 3 | pycparser-2.20.dist-info/METADATA,sha256=5_RDLTEfmg8dh29oc053jTNp_OL82PllsggkGQTU_Ds,907 4 | pycparser-2.20.dist-info/RECORD,, 5 | pycparser-2.20.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110 6 | pycparser-2.20.dist-info/top_level.txt,sha256=c-lPcS74L_8KoH7IE6PQF5ofyirRQNV4VhkbSFIPeWM,10 7 | pycparser/__init__.py,sha256=O2ajDXgU2_NI52hUFV8WeAjCR5L-sclmaXerpcxqgPo,2815 8 | pycparser/__pycache__/__init__.cpython-37.pyc,, 9 | pycparser/__pycache__/_ast_gen.cpython-37.pyc,, 10 | pycparser/__pycache__/_build_tables.cpython-37.pyc,, 11 | pycparser/__pycache__/ast_transforms.cpython-37.pyc,, 12 | pycparser/__pycache__/c_ast.cpython-37.pyc,, 13 | pycparser/__pycache__/c_generator.cpython-37.pyc,, 14 | pycparser/__pycache__/c_lexer.cpython-37.pyc,, 15 | pycparser/__pycache__/c_parser.cpython-37.pyc,, 16 | pycparser/__pycache__/lextab.cpython-37.pyc,, 17 | pycparser/__pycache__/plyparser.cpython-37.pyc,, 18 | pycparser/__pycache__/yacctab.cpython-37.pyc,, 19 | pycparser/_ast_gen.py,sha256=_LbRr_kKa2EHeb7y0gV525JV29nzCUbTH4oZ-9I4qIs,10607 20 | pycparser/_build_tables.py,sha256=oZCd3Plhq-vkV-QuEsaahcf-jUI6-HgKsrAL9gvFzuU,1039 21 | pycparser/_c_ast.cfg,sha256=1W8-DHa5RqZvyhha_0b4VvKL0CEYv9W0xFs_YwiyEHY,4206 22 | pycparser/ast_transforms.py,sha256=93ENKENTlugzFehnrQ0fdprijVdNt_ACCPygMxH4v7Q,3648 23 | pycparser/c_ast.py,sha256=JdDyC3QUZBfX9wVu2ENOrQQPbc737Jmf8Vtozhukayo,30233 24 | pycparser/c_generator.py,sha256=AwzNyE_rOFK2gzK0J5pCWDqfk7V8KL54ITFRf9m4GlY,15365 25 | pycparser/c_lexer.py,sha256=GWPUkwFe6F00gTAKIPAx4xs8-J-at_oGwEHnrKF4teM,16208 26 | pycparser/c_parser.py,sha256=w74N4tFGQ3TETIqUwClZIcbl-V4hFeJSPG2halVgUVs,69746 27 | pycparser/lextab.py,sha256=FyjRIsaq2wViDqJNYScURuc7GDW5F12VuYxOJLh1j4g,7011 28 | pycparser/ply/__init__.py,sha256=q4s86QwRsYRa20L9ueSxfh-hPihpftBjDOvYa2_SS2Y,102 29 | pycparser/ply/__pycache__/__init__.cpython-37.pyc,, 30 | pycparser/ply/__pycache__/cpp.cpython-37.pyc,, 31 | pycparser/ply/__pycache__/ctokens.cpython-37.pyc,, 32 | pycparser/ply/__pycache__/lex.cpython-37.pyc,, 33 | pycparser/ply/__pycache__/yacc.cpython-37.pyc,, 34 | pycparser/ply/__pycache__/ygen.cpython-37.pyc,, 35 | pycparser/ply/cpp.py,sha256=UtC3ylTWp5_1MKA-PLCuwKQR8zSOnlGuGGIdzj8xS98,33282 36 | pycparser/ply/ctokens.py,sha256=MKksnN40TehPhgVfxCJhjj_BjL943apreABKYz-bl0Y,3177 37 | pycparser/ply/lex.py,sha256=7Qol57x702HZwjA3ZLp-84CUEWq1EehW-N67Wzghi-M,42918 38 | pycparser/ply/yacc.py,sha256=eatSDkRLgRr6X3-hoDk_SQQv065R0BdL2K7fQ54CgVM,137323 39 | pycparser/ply/ygen.py,sha256=2JYNeYtrPz1JzLSLO3d4GsS8zJU8jY_I_CR1VI9gWrA,2251 40 | pycparser/plyparser.py,sha256=saGNjpsgncQz-hHEh45f28BLqopTxHffaJg_9BCZhi8,4873 41 | pycparser/yacctab.py,sha256=KOewsHNgbSYaYrLvDJr7K3jXj-7qou0ngyNEnhDmyB4,169715 42 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser-2.20.dist-info/WHEEL: -------------------------------------------------------------------------------- 1 | Wheel-Version: 1.0 2 | Generator: bdist_wheel (0.34.2) 3 | Root-Is-Purelib: true 4 | Tag: py2-none-any 5 | Tag: py3-none-any 6 | 7 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser-2.20.dist-info/top_level.txt: -------------------------------------------------------------------------------- 1 | pycparser 2 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser/__init__.py: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------- 2 | # pycparser: __init__.py 3 | # 4 | # This package file exports some convenience functions for 5 | # interacting with pycparser 6 | # 7 | # Eli Bendersky [https://eli.thegreenplace.net/] 8 | # License: BSD 9 | #----------------------------------------------------------------- 10 | __all__ = ['c_lexer', 'c_parser', 'c_ast'] 11 | __version__ = '2.20' 12 | 13 | import io 14 | from subprocess import check_output 15 | from .c_parser import CParser 16 | 17 | 18 | def preprocess_file(filename, cpp_path='cpp', cpp_args=''): 19 | """ Preprocess a file using cpp. 20 | 21 | filename: 22 | Name of the file you want to preprocess. 23 | 24 | cpp_path: 25 | cpp_args: 26 | Refer to the documentation of parse_file for the meaning of these 27 | arguments. 28 | 29 | When successful, returns the preprocessed file's contents. 30 | Errors from cpp will be printed out. 31 | """ 32 | path_list = [cpp_path] 33 | if isinstance(cpp_args, list): 34 | path_list += cpp_args 35 | elif cpp_args != '': 36 | path_list += [cpp_args] 37 | path_list += [filename] 38 | 39 | try: 40 | # Note the use of universal_newlines to treat all newlines 41 | # as \n for Python's purpose 42 | text = check_output(path_list, universal_newlines=True) 43 | except OSError as e: 44 | raise RuntimeError("Unable to invoke 'cpp'. " + 45 | 'Make sure its path was passed correctly\n' + 46 | ('Original error: %s' % e)) 47 | 48 | return text 49 | 50 | 51 | def parse_file(filename, use_cpp=False, cpp_path='cpp', cpp_args='', 52 | parser=None): 53 | """ Parse a C file using pycparser. 54 | 55 | filename: 56 | Name of the file you want to parse. 57 | 58 | use_cpp: 59 | Set to True if you want to execute the C pre-processor 60 | on the file prior to parsing it. 61 | 62 | cpp_path: 63 | If use_cpp is True, this is the path to 'cpp' on your 64 | system. If no path is provided, it attempts to just 65 | execute 'cpp', so it must be in your PATH. 66 | 67 | cpp_args: 68 | If use_cpp is True, set this to the command line arguments strings 69 | to cpp. Be careful with quotes - it's best to pass a raw string 70 | (r'') here. For example: 71 | r'-I../utils/fake_libc_include' 72 | If several arguments are required, pass a list of strings. 73 | 74 | parser: 75 | Optional parser object to be used instead of the default CParser 76 | 77 | When successful, an AST is returned. ParseError can be 78 | thrown if the file doesn't parse successfully. 79 | 80 | Errors from cpp will be printed out. 81 | """ 82 | if use_cpp: 83 | text = preprocess_file(filename, cpp_path, cpp_args) 84 | else: 85 | with io.open(filename) as f: 86 | text = f.read() 87 | 88 | if parser is None: 89 | parser = CParser() 90 | return parser.parse(text, filename) 91 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser/_build_tables.py: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------- 2 | # pycparser: _build_tables.py 3 | # 4 | # A dummy for generating the lexing/parsing tables and and 5 | # compiling them into .pyc for faster execution in optimized mode. 6 | # Also generates AST code from the configuration file. 7 | # Should be called from the pycparser directory. 8 | # 9 | # Eli Bendersky [https://eli.thegreenplace.net/] 10 | # License: BSD 11 | #----------------------------------------------------------------- 12 | 13 | # Insert '.' and '..' as first entries to the search path for modules. 14 | # Restricted environments like embeddable python do not include the 15 | # current working directory on startup. 16 | import sys 17 | sys.path[0:0] = ['.', '..'] 18 | 19 | # Generate c_ast.py 20 | from _ast_gen import ASTCodeGenerator 21 | ast_gen = ASTCodeGenerator('_c_ast.cfg') 22 | ast_gen.generate(open('c_ast.py', 'w')) 23 | 24 | from pycparser import c_parser 25 | 26 | # Generates the tables 27 | # 28 | c_parser.CParser( 29 | lex_optimize=True, 30 | yacc_debug=False, 31 | yacc_optimize=True) 32 | 33 | # Load to compile into .pyc 34 | # 35 | import lextab 36 | import yacctab 37 | import c_ast 38 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser/ast_transforms.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # pycparser: ast_transforms.py 3 | # 4 | # Some utilities used by the parser to create a friendlier AST. 5 | # 6 | # Eli Bendersky [https://eli.thegreenplace.net/] 7 | # License: BSD 8 | #------------------------------------------------------------------------------ 9 | 10 | from . import c_ast 11 | 12 | 13 | def fix_switch_cases(switch_node): 14 | """ The 'case' statements in a 'switch' come out of parsing with one 15 | child node, so subsequent statements are just tucked to the parent 16 | Compound. Additionally, consecutive (fall-through) case statements 17 | come out messy. This is a peculiarity of the C grammar. The following: 18 | 19 | switch (myvar) { 20 | case 10: 21 | k = 10; 22 | p = k + 1; 23 | return 10; 24 | case 20: 25 | case 30: 26 | return 20; 27 | default: 28 | break; 29 | } 30 | 31 | Creates this tree (pseudo-dump): 32 | 33 | Switch 34 | ID: myvar 35 | Compound: 36 | Case 10: 37 | k = 10 38 | p = k + 1 39 | return 10 40 | Case 20: 41 | Case 30: 42 | return 20 43 | Default: 44 | break 45 | 46 | The goal of this transform is to fix this mess, turning it into the 47 | following: 48 | 49 | Switch 50 | ID: myvar 51 | Compound: 52 | Case 10: 53 | k = 10 54 | p = k + 1 55 | return 10 56 | Case 20: 57 | Case 30: 58 | return 20 59 | Default: 60 | break 61 | 62 | A fixed AST node is returned. The argument may be modified. 63 | """ 64 | assert isinstance(switch_node, c_ast.Switch) 65 | if not isinstance(switch_node.stmt, c_ast.Compound): 66 | return switch_node 67 | 68 | # The new Compound child for the Switch, which will collect children in the 69 | # correct order 70 | new_compound = c_ast.Compound([], switch_node.stmt.coord) 71 | 72 | # The last Case/Default node 73 | last_case = None 74 | 75 | # Goes over the children of the Compound below the Switch, adding them 76 | # either directly below new_compound or below the last Case as appropriate 77 | # (for `switch(cond) {}`, block_items would have been None) 78 | for child in (switch_node.stmt.block_items or []): 79 | if isinstance(child, (c_ast.Case, c_ast.Default)): 80 | # If it's a Case/Default: 81 | # 1. Add it to the Compound and mark as "last case" 82 | # 2. If its immediate child is also a Case or Default, promote it 83 | # to a sibling. 84 | new_compound.block_items.append(child) 85 | _extract_nested_case(child, new_compound.block_items) 86 | last_case = new_compound.block_items[-1] 87 | else: 88 | # Other statements are added as children to the last case, if it 89 | # exists. 90 | if last_case is None: 91 | new_compound.block_items.append(child) 92 | else: 93 | last_case.stmts.append(child) 94 | 95 | switch_node.stmt = new_compound 96 | return switch_node 97 | 98 | 99 | def _extract_nested_case(case_node, stmts_list): 100 | """ Recursively extract consecutive Case statements that are made nested 101 | by the parser and add them to the stmts_list. 102 | """ 103 | if isinstance(case_node.stmts[0], (c_ast.Case, c_ast.Default)): 104 | stmts_list.append(case_node.stmts.pop()) 105 | _extract_nested_case(stmts_list[-1], stmts_list) 106 | 107 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser/ply/__init__.py: -------------------------------------------------------------------------------- 1 | # PLY package 2 | # Author: David Beazley (dave@dabeaz.com) 3 | 4 | __version__ = '3.9' 5 | __all__ = ['lex','yacc'] 6 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser/ply/ctokens.py: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------- 2 | # ctokens.py 3 | # 4 | # Token specifications for symbols in ANSI C and C++. This file is 5 | # meant to be used as a library in other tokenizers. 6 | # ---------------------------------------------------------------------- 7 | 8 | # Reserved words 9 | 10 | tokens = [ 11 | # Literals (identifier, integer constant, float constant, string constant, char const) 12 | 'ID', 'TYPEID', 'INTEGER', 'FLOAT', 'STRING', 'CHARACTER', 13 | 14 | # Operators (+,-,*,/,%,|,&,~,^,<<,>>, ||, &&, !, <, <=, >, >=, ==, !=) 15 | 'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'MODULO', 16 | 'OR', 'AND', 'NOT', 'XOR', 'LSHIFT', 'RSHIFT', 17 | 'LOR', 'LAND', 'LNOT', 18 | 'LT', 'LE', 'GT', 'GE', 'EQ', 'NE', 19 | 20 | # Assignment (=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=) 21 | 'EQUALS', 'TIMESEQUAL', 'DIVEQUAL', 'MODEQUAL', 'PLUSEQUAL', 'MINUSEQUAL', 22 | 'LSHIFTEQUAL','RSHIFTEQUAL', 'ANDEQUAL', 'XOREQUAL', 'OREQUAL', 23 | 24 | # Increment/decrement (++,--) 25 | 'INCREMENT', 'DECREMENT', 26 | 27 | # Structure dereference (->) 28 | 'ARROW', 29 | 30 | # Ternary operator (?) 31 | 'TERNARY', 32 | 33 | # Delimeters ( ) [ ] { } , . ; : 34 | 'LPAREN', 'RPAREN', 35 | 'LBRACKET', 'RBRACKET', 36 | 'LBRACE', 'RBRACE', 37 | 'COMMA', 'PERIOD', 'SEMI', 'COLON', 38 | 39 | # Ellipsis (...) 40 | 'ELLIPSIS', 41 | ] 42 | 43 | # Operators 44 | t_PLUS = r'\+' 45 | t_MINUS = r'-' 46 | t_TIMES = r'\*' 47 | t_DIVIDE = r'/' 48 | t_MODULO = r'%' 49 | t_OR = r'\|' 50 | t_AND = r'&' 51 | t_NOT = r'~' 52 | t_XOR = r'\^' 53 | t_LSHIFT = r'<<' 54 | t_RSHIFT = r'>>' 55 | t_LOR = r'\|\|' 56 | t_LAND = r'&&' 57 | t_LNOT = r'!' 58 | t_LT = r'<' 59 | t_GT = r'>' 60 | t_LE = r'<=' 61 | t_GE = r'>=' 62 | t_EQ = r'==' 63 | t_NE = r'!=' 64 | 65 | # Assignment operators 66 | 67 | t_EQUALS = r'=' 68 | t_TIMESEQUAL = r'\*=' 69 | t_DIVEQUAL = r'/=' 70 | t_MODEQUAL = r'%=' 71 | t_PLUSEQUAL = r'\+=' 72 | t_MINUSEQUAL = r'-=' 73 | t_LSHIFTEQUAL = r'<<=' 74 | t_RSHIFTEQUAL = r'>>=' 75 | t_ANDEQUAL = r'&=' 76 | t_OREQUAL = r'\|=' 77 | t_XOREQUAL = r'\^=' 78 | 79 | # Increment/decrement 80 | t_INCREMENT = r'\+\+' 81 | t_DECREMENT = r'--' 82 | 83 | # -> 84 | t_ARROW = r'->' 85 | 86 | # ? 87 | t_TERNARY = r'\?' 88 | 89 | # Delimeters 90 | t_LPAREN = r'\(' 91 | t_RPAREN = r'\)' 92 | t_LBRACKET = r'\[' 93 | t_RBRACKET = r'\]' 94 | t_LBRACE = r'\{' 95 | t_RBRACE = r'\}' 96 | t_COMMA = r',' 97 | t_PERIOD = r'\.' 98 | t_SEMI = r';' 99 | t_COLON = r':' 100 | t_ELLIPSIS = r'\.\.\.' 101 | 102 | # Identifiers 103 | t_ID = r'[A-Za-z_][A-Za-z0-9_]*' 104 | 105 | # Integer literal 106 | t_INTEGER = r'\d+([uU]|[lL]|[uU][lL]|[lL][uU])?' 107 | 108 | # Floating literal 109 | t_FLOAT = r'((\d+)(\.\d+)(e(\+|-)?(\d+))? | (\d+)e(\+|-)?(\d+))([lL]|[fF])?' 110 | 111 | # String literal 112 | t_STRING = r'\"([^\\\n]|(\\.))*?\"' 113 | 114 | # Character constant 'c' or L'c' 115 | t_CHARACTER = r'(L)?\'([^\\\n]|(\\.))*?\'' 116 | 117 | # Comment (C-Style) 118 | def t_COMMENT(t): 119 | r'/\*(.|\n)*?\*/' 120 | t.lexer.lineno += t.value.count('\n') 121 | return t 122 | 123 | # Comment (C++-Style) 124 | def t_CPPCOMMENT(t): 125 | r'//.*\n' 126 | t.lexer.lineno += 1 127 | return t 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /modules/common/dep/pycparser/ply/ygen.py: -------------------------------------------------------------------------------- 1 | # ply: ygen.py 2 | # 3 | # This is a support program that auto-generates different versions of the YACC parsing 4 | # function with different features removed for the purposes of performance. 5 | # 6 | # Users should edit the method LParser.parsedebug() in yacc.py. The source code 7 | # for that method is then used to create the other methods. See the comments in 8 | # yacc.py for further details. 9 | 10 | import os.path 11 | import shutil 12 | 13 | def get_source_range(lines, tag): 14 | srclines = enumerate(lines) 15 | start_tag = '#--! %s-start' % tag 16 | end_tag = '#--! %s-end' % tag 17 | 18 | for start_index, line in srclines: 19 | if line.strip().startswith(start_tag): 20 | break 21 | 22 | for end_index, line in srclines: 23 | if line.strip().endswith(end_tag): 24 | break 25 | 26 | return (start_index + 1, end_index) 27 | 28 | def filter_section(lines, tag): 29 | filtered_lines = [] 30 | include = True 31 | tag_text = '#--! %s' % tag 32 | for line in lines: 33 | if line.strip().startswith(tag_text): 34 | include = not include 35 | elif include: 36 | filtered_lines.append(line) 37 | return filtered_lines 38 | 39 | def main(): 40 | dirname = os.path.dirname(__file__) 41 | shutil.copy2(os.path.join(dirname, 'yacc.py'), os.path.join(dirname, 'yacc.py.bak')) 42 | with open(os.path.join(dirname, 'yacc.py'), 'r') as f: 43 | lines = f.readlines() 44 | 45 | parse_start, parse_end = get_source_range(lines, 'parsedebug') 46 | parseopt_start, parseopt_end = get_source_range(lines, 'parseopt') 47 | parseopt_notrack_start, parseopt_notrack_end = get_source_range(lines, 'parseopt-notrack') 48 | 49 | # Get the original source 50 | orig_lines = lines[parse_start:parse_end] 51 | 52 | # Filter the DEBUG sections out 53 | parseopt_lines = filter_section(orig_lines, 'DEBUG') 54 | 55 | # Filter the TRACKING sections out 56 | parseopt_notrack_lines = filter_section(parseopt_lines, 'TRACKING') 57 | 58 | # Replace the parser source sections with updated versions 59 | lines[parseopt_notrack_start:parseopt_notrack_end] = parseopt_notrack_lines 60 | lines[parseopt_start:parseopt_end] = parseopt_lines 61 | 62 | lines = [line.rstrip()+'\n' for line in lines] 63 | with open(os.path.join(dirname, 'yacc.py'), 'w') as f: 64 | f.writelines(lines) 65 | 66 | print('Updated yacc.py') 67 | 68 | if __name__ == '__main__': 69 | main() 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /modules/common/dep/six-1.15.0.dist-info/INSTALLER: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /modules/common/dep/six-1.15.0.dist-info/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2020 Benjamin Peterson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /modules/common/dep/six-1.15.0.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: six 3 | Version: 1.15.0 4 | Summary: Python 2 and 3 compatibility utilities 5 | Home-page: https://github.com/benjaminp/six 6 | Author: Benjamin Peterson 7 | Author-email: benjamin@python.org 8 | License: MIT 9 | Platform: UNKNOWN 10 | Classifier: Development Status :: 5 - Production/Stable 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 3 13 | Classifier: Intended Audience :: Developers 14 | Classifier: License :: OSI Approved :: MIT License 15 | Classifier: Topic :: Software Development :: Libraries 16 | Classifier: Topic :: Utilities 17 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.* 18 | 19 | .. image:: https://img.shields.io/pypi/v/six.svg 20 | :target: https://pypi.org/project/six/ 21 | :alt: six on PyPI 22 | 23 | .. image:: https://travis-ci.org/benjaminp/six.svg?branch=master 24 | :target: https://travis-ci.org/benjaminp/six 25 | :alt: six on TravisCI 26 | 27 | .. image:: https://readthedocs.org/projects/six/badge/?version=latest 28 | :target: https://six.readthedocs.io/ 29 | :alt: six's documentation on Read the Docs 30 | 31 | .. image:: https://img.shields.io/badge/license-MIT-green.svg 32 | :target: https://github.com/benjaminp/six/blob/master/LICENSE 33 | :alt: MIT License badge 34 | 35 | Six is a Python 2 and 3 compatibility library. It provides utility functions 36 | for smoothing over the differences between the Python versions with the goal of 37 | writing Python code that is compatible on both Python versions. See the 38 | documentation for more information on what is provided. 39 | 40 | Six supports Python 2.7 and 3.3+. It is contained in only one Python 41 | file, so it can be easily copied into your project. (The copyright and license 42 | notice must be retained.) 43 | 44 | Online documentation is at https://six.readthedocs.io/. 45 | 46 | Bugs can be reported to https://github.com/benjaminp/six. The code can also 47 | be found there. 48 | 49 | 50 | -------------------------------------------------------------------------------- /modules/common/dep/six-1.15.0.dist-info/RECORD: -------------------------------------------------------------------------------- 1 | __pycache__/six.cpython-37.pyc,, 2 | six-1.15.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 3 | six-1.15.0.dist-info/LICENSE,sha256=i7hQxWWqOJ_cFvOkaWWtI9gq3_YPI5P8J2K2MYXo5sk,1066 4 | six-1.15.0.dist-info/METADATA,sha256=W6rlyoeMZHXh6srP9NXNsm0rjAf_660re8WdH5TBT8E,1795 5 | six-1.15.0.dist-info/RECORD,, 6 | six-1.15.0.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110 7 | six-1.15.0.dist-info/top_level.txt,sha256=_iVH_iYEtEXnD8nYGQYpYFUvkUW9sEO1GYbkeKSAais,4 8 | six.py,sha256=U4Z_yv534W5CNyjY9i8V1OXY2SjAny8y2L5vDLhhThM,34159 9 | -------------------------------------------------------------------------------- /modules/common/dep/six-1.15.0.dist-info/WHEEL: -------------------------------------------------------------------------------- 1 | Wheel-Version: 1.0 2 | Generator: bdist_wheel (0.34.2) 3 | Root-Is-Purelib: true 4 | Tag: py2-none-any 5 | Tag: py3-none-any 6 | 7 | -------------------------------------------------------------------------------- /modules/common/dep/six-1.15.0.dist-info/top_level.txt: -------------------------------------------------------------------------------- 1 | six 2 | -------------------------------------------------------------------------------- /modules/common/dep/xattr-0.9.7.dist-info/INSTALLER: -------------------------------------------------------------------------------- 1 | pip 2 | -------------------------------------------------------------------------------- /modules/common/dep/xattr-0.9.7.dist-info/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This is the MIT license. This software may also be distributed under the same terms as Python (the PSF license). 2 | 3 | Copyright (c) 2004 Bob Ippolito. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /modules/common/dep/xattr-0.9.7.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: xattr 3 | Version: 0.9.7 4 | Summary: Python wrapper for extended filesystem attributes 5 | Home-page: http://github.com/xattr/xattr 6 | Author: Bob Ippolito 7 | Author-email: bob@redivi.com 8 | License: MIT License 9 | Platform: MacOS X 10 | Platform: Linux 11 | Platform: FreeBSD 12 | Platform: Solaris 13 | Classifier: Environment :: Console 14 | Classifier: Intended Audience :: Developers 15 | Classifier: License :: OSI Approved :: MIT License 16 | Classifier: Natural Language :: English 17 | Classifier: Operating System :: MacOS :: MacOS X 18 | Classifier: Operating System :: POSIX :: Linux 19 | Classifier: Operating System :: POSIX :: BSD :: FreeBSD 20 | Classifier: Programming Language :: Python 21 | Classifier: Programming Language :: Python :: 2 22 | Classifier: Programming Language :: Python :: 3 23 | Classifier: Topic :: Software Development :: Libraries :: Python Modules 24 | Requires-Dist: cffi (>=1.0.0) 25 | 26 | 27 | Extended attributes extend the basic attributes of files and directories 28 | in the file system. They are stored as name:data pairs associated with 29 | file system objects (files, directories, symlinks, etc). 30 | 31 | Extended attributes are currently only available on Darwin 8.0+ (Mac OS X 10.4) 32 | and Linux 2.6+. Experimental support is included for Solaris and FreeBSD. 33 | 34 | 35 | -------------------------------------------------------------------------------- /modules/common/dep/xattr-0.9.7.dist-info/RECORD: -------------------------------------------------------------------------------- 1 | ../../bin/xattr,sha256=TxJlcDrtlt6ay2eBfGGUy9jP45aG4CPO4sD64ey9c1k,260 2 | xattr-0.9.7.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 3 | xattr-0.9.7.dist-info/LICENSE.txt,sha256=8q6jLbdqJC7GYArvyHXRyfBB9cf9RmAiPos-ip4FCb0,1172 4 | xattr-0.9.7.dist-info/METADATA,sha256=r3J8NDTZaL0bo6AXyQZmqoCFO0chejPu-lMoAzxjvps,1215 5 | xattr-0.9.7.dist-info/RECORD,, 6 | xattr-0.9.7.dist-info/WHEEL,sha256=ls0mk9oUTWRDk9fREN04Ii6vOvKEtq2_kiygdMYwOW8,111 7 | xattr-0.9.7.dist-info/entry_points.txt,sha256=0SjmtcSXURBLDEiZ9N1R82g7rAmXYLZBrlo0Kl4a8pU,43 8 | xattr-0.9.7.dist-info/top_level.txt,sha256=ZUHZcuN2meJ0miIIsDb0KaElzOvDRrIIl8CZjnvRUrc,11 9 | xattr/__init__.py,sha256=2QwzJPMBnxYJE_nMyNQp99QaSOcNsFo9rvCEu0wc2SE,5319 10 | xattr/__pycache__/__init__.cpython-37.pyc,, 11 | xattr/__pycache__/compat.cpython-37.pyc,, 12 | xattr/__pycache__/lib.cpython-37.pyc,, 13 | xattr/__pycache__/lib_build.cpython-37.pyc,, 14 | xattr/__pycache__/pyxattr_compat.cpython-37.pyc,, 15 | xattr/__pycache__/tool.cpython-37.pyc,, 16 | xattr/_lib.abi3.so,sha256=vyjurMR0c1KmNBRFJ6L0a3eKJxFDWy4Ean8jITWIusU,17188 17 | xattr/compat.py,sha256=6IcJpgeuGot1uhl-RJy_jbWkVO5utb09Qr2dhRj0TlM,680 18 | xattr/lib.py,sha256=8JmtCRPRvS-iGUP6gkktYw9wonF-WwuN3wnEUXzxrf4,3752 19 | xattr/lib_build.py,sha256=o1Lo6Du5uNTm6rBqV5jHbaFNcQZnaoQVQcnPA5463vo,342 20 | xattr/pyxattr_compat.py,sha256=0H6gVI3W5d-80b1_wm72_tfvvEcwzgLDViisCSUfX-w,3762 21 | xattr/tool.py,sha256=KCyK0HZsDsWPLNFiQglO1MhHCshrXUlwrJWw_Uwq_6Y,6821 22 | -------------------------------------------------------------------------------- /modules/common/dep/xattr-0.9.7.dist-info/WHEEL: -------------------------------------------------------------------------------- 1 | Wheel-Version: 1.0 2 | Generator: bdist_wheel (0.33.6) 3 | Root-Is-Purelib: false 4 | Tag: cp37-cp37m-macosx_10_13_x86_64 5 | 6 | -------------------------------------------------------------------------------- /modules/common/dep/xattr-0.9.7.dist-info/entry_points.txt: -------------------------------------------------------------------------------- 1 | [console_scripts] 2 | xattr = xattr.tool:main 3 | 4 | -------------------------------------------------------------------------------- /modules/common/dep/xattr-0.9.7.dist-info/top_level.txt: -------------------------------------------------------------------------------- 1 | _lib 2 | xattr 3 | -------------------------------------------------------------------------------- /modules/common/dep/xattr/_lib.abi3.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/dep/xattr/_lib.abi3.so -------------------------------------------------------------------------------- /modules/common/dep/xattr/compat.py: -------------------------------------------------------------------------------- 1 | """Python 3 compatibility shims 2 | """ 3 | import os 4 | import sys 5 | import codecs 6 | 7 | if sys.version_info[0] < 3: 8 | integer_types = (int, long) 9 | text_type = unicode 10 | binary_type = str 11 | else: 12 | integer_types = (int,) 13 | text_type = str 14 | binary_type = bytes 15 | 16 | fs_encoding = sys.getfilesystemencoding() 17 | fs_errors = 'strict' 18 | if fs_encoding != 'mbcs': 19 | try: 20 | codecs.lookup('surrogateescape') 21 | fs_errors = 'surrogateescape' 22 | except LookupError: 23 | pass 24 | try: 25 | fs_encode = os.fsencode 26 | except AttributeError: 27 | def fs_encode(val): 28 | if not isinstance(val, bytes): 29 | return val.encode(fs_encoding, fs_errors) 30 | else: 31 | return val 32 | -------------------------------------------------------------------------------- /modules/common/dep/xattr/lib.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from .compat import fs_encode 5 | 6 | # try: 7 | # from ._lib import lib, ffi 8 | # except ImportError: 9 | from .lib_build import ffi, c_source 10 | lib = ffi.verify(c_source) 11 | 12 | XATTR_NOFOLLOW = lib.XATTR_XATTR_NOFOLLOW 13 | XATTR_CREATE = lib.XATTR_XATTR_CREATE 14 | XATTR_REPLACE = lib.XATTR_XATTR_REPLACE 15 | XATTR_NOSECURITY = lib.XATTR_XATTR_NOSECURITY 16 | XATTR_MAXNAMELEN = lib.XATTR_MAXNAMELEN 17 | 18 | XATTR_FINDERINFO_NAME = "com.apple.FinderInfo" 19 | XATTR_RESOURCEFORK_NAME = "com.apple.ResourceFork" 20 | 21 | 22 | def _check_bytes(val): 23 | if not isinstance(val, bytes): 24 | raise TypeError( 25 | "Value must be bytes, %s was passed." % type(val).__name__ 26 | ) 27 | 28 | 29 | def error(path=None): 30 | errno = ffi.errno 31 | strerror = os.strerror(ffi.errno) 32 | if path: 33 | raise IOError(errno, strerror, path) 34 | else: 35 | raise IOError(errno, strerror) 36 | 37 | 38 | def _getxattr(path, name, size=0, position=0, options=0): 39 | """ 40 | getxattr(path, name, size=0, position=0, options=0) -> str 41 | """ 42 | path = fs_encode(path) 43 | name = fs_encode(name) 44 | if size == 0: 45 | res = lib.xattr_getxattr(path, name, ffi.NULL, 0, position, options) 46 | if res == -1: 47 | raise error(path) 48 | size = res 49 | buf = ffi.new("char[]", size) 50 | res = lib.xattr_getxattr(path, name, buf, size, position, options) 51 | if res == -1: 52 | raise error(path) 53 | return ffi.buffer(buf)[:res] 54 | 55 | 56 | def _fgetxattr(fd, name, size=0, position=0, options=0): 57 | """ 58 | fgetxattr(fd, name, size=0, position=0, options=0) -> str 59 | """ 60 | name = fs_encode(name) 61 | if size == 0: 62 | res = lib.xattr_fgetxattr(fd, name, ffi.NULL, 0, position, options) 63 | if res == -1: 64 | raise error() 65 | size = res 66 | buf = ffi.new("char[]", size) 67 | res = lib.xattr_fgetxattr(fd, name, buf, size, position, options) 68 | if res == -1: 69 | raise error() 70 | return ffi.buffer(buf)[:res] 71 | 72 | 73 | def _setxattr(path, name, value, position=0, options=0): 74 | """ 75 | setxattr(path, name, value, position=0, options=0) -> None 76 | """ 77 | _check_bytes(value) 78 | path = fs_encode(path) 79 | name = fs_encode(name) 80 | res = lib.xattr_setxattr(path, name, value, len(value), position, options) 81 | if res: 82 | raise error(path) 83 | 84 | 85 | def _fsetxattr(fd, name, value, position=0, options=0): 86 | """ 87 | fsetxattr(fd, name, value, position=0, options=0) -> None 88 | """ 89 | _check_bytes(value) 90 | name = fs_encode(name) 91 | res = lib.xattr_fsetxattr(fd, name, value, len(value), position, options) 92 | if res: 93 | raise error() 94 | 95 | 96 | def _removexattr(path, name, options=0): 97 | """ 98 | removexattr(path, name, options=0) -> None 99 | """ 100 | path = fs_encode(path) 101 | name = fs_encode(name) 102 | res = lib.xattr_removexattr(path, name, options) 103 | if res: 104 | raise error(path) 105 | 106 | 107 | def _fremovexattr(fd, name, options=0): 108 | """ 109 | fremovexattr(fd, name, options=0) -> None 110 | """ 111 | name = fs_encode(name) 112 | res = lib.xattr_fremovexattr(fd, name, options) 113 | if res: 114 | raise error() 115 | 116 | 117 | def _listxattr(path, options=0): 118 | """ 119 | listxattr(path, options=0) -> str 120 | """ 121 | path = fs_encode(path) 122 | res = lib.xattr_listxattr(path, ffi.NULL, 0, options) 123 | if res == -1: 124 | raise error(path) 125 | elif res == 0: 126 | return b"" 127 | buf = ffi.new("char[]", res) 128 | res = lib.xattr_listxattr(path, buf, res, options) 129 | if res == -1: 130 | raise error(path) 131 | return ffi.buffer(buf)[:res] 132 | 133 | 134 | def _flistxattr(fd, options=0): 135 | """ 136 | flistxattr(fd, options=0) -> str 137 | """ 138 | res = lib.xattr_flistxattr(fd, ffi.NULL, 0, options) 139 | if res == -1: 140 | raise error() 141 | buf = ffi.new("char[]", res) 142 | res = lib.xattr_flistxattr(fd, buf, res, options) 143 | if res == -1: 144 | raise error() 145 | return ffi.buffer(buf)[:res] 146 | -------------------------------------------------------------------------------- /modules/common/dep/xattr/lib_build.h: -------------------------------------------------------------------------------- 1 | #define XATTR_XATTR_NOFOLLOW ... 2 | #define XATTR_XATTR_CREATE ... 3 | #define XATTR_XATTR_REPLACE ... 4 | #define XATTR_XATTR_NOSECURITY ... 5 | #define XATTR_MAXNAMELEN ... 6 | 7 | ssize_t xattr_getxattr(const char *, const char *, void *, ssize_t, uint32_t, int); 8 | ssize_t xattr_fgetxattr(int, const char *, void *, ssize_t, uint32_t, int); 9 | 10 | ssize_t xattr_setxattr(const char *, const char *, void *, ssize_t, uint32_t, int); 11 | ssize_t xattr_fsetxattr(int, const char *, void *, ssize_t, uint32_t, int); 12 | 13 | ssize_t xattr_removexattr(const char *, const char *, int); 14 | ssize_t xattr_fremovexattr(int, const char *, int); 15 | 16 | ssize_t xattr_listxattr(const char *, char *, size_t, int); 17 | ssize_t xattr_flistxattr(int, char *, size_t, int); 18 | -------------------------------------------------------------------------------- /modules/common/dep/xattr/lib_build.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | if sys.version_info[0] == 3: 5 | if sys.version_info[1] == 7: 6 | from ..cffi37 import FFI 7 | elif sys.version_info[1] == 8: 8 | from ..cffi38 import FFI 9 | elif sys.version_info[1] == 9: 10 | from ..cffi39 import FFI 11 | 12 | 13 | PATH = os.path.dirname(__file__) 14 | 15 | with open(os.path.join(PATH, 'lib_build.h')) as hf: 16 | c_header = hf.read() 17 | with open(os.path.join(PATH, 'lib_build.c')) as cf: 18 | c_source = cf.read() 19 | 20 | ffi = FFI() 21 | ffi.cdef(c_header) 22 | ffi.set_source('_lib', c_source) 23 | 24 | if __name__ == '__main__': 25 | ffi.compile() 26 | -------------------------------------------------------------------------------- /modules/common/dep/xattr/pyxattr_compat.py: -------------------------------------------------------------------------------- 1 | """ 2 | pyxattr and xattr have differing API, for example xattr assumes 3 | that (like on OSX) attribute keys are valid UTF-8, while pyxattr 4 | just passes through the raw bytestring. 5 | 6 | This module provides compatibility for the pyxattr API. 7 | """ 8 | 9 | import sys 10 | 11 | from .compat import (binary_type, integer_types, text_type) 12 | from .lib import (XATTR_NOFOLLOW, XATTR_CREATE, XATTR_REPLACE, 13 | XATTR_NOSECURITY, XATTR_MAXNAMELEN, XATTR_FINDERINFO_NAME, 14 | XATTR_RESOURCEFORK_NAME, _getxattr, _fgetxattr, _setxattr, _fsetxattr, 15 | _removexattr, _fremovexattr, _listxattr, _flistxattr) 16 | 17 | __all__ = [ 18 | "NS_SECURITY", "NS_USER", "NS_SYSTEM", "NS_TRUSTED", 19 | "getxattr", "get", "get_all", "setxattr", "set", 20 | "removexattr", "remove", "listxattr", "list" 21 | ] 22 | 23 | NS_SECURITY = "security" 24 | NS_USER = "user" 25 | NS_SYSTEM = "system" 26 | NS_TRUSTED = "trusted" 27 | 28 | _NO_NS = object() 29 | 30 | _fsencoding = sys.getfilesystemencoding() 31 | 32 | def _call(item, name_func, fd_func, *args): 33 | if isinstance(item, integer_types): 34 | return fd_func(item, *args) 35 | elif hasattr(item, 'fileno'): 36 | return fd_func(item.fileno(), *args) 37 | elif isinstance(item, binary_type): 38 | return name_func(item, *args) 39 | elif isinstance(item, text_type): 40 | item = item.encode(_fsencoding) 41 | return name_func(item, *args) 42 | else: 43 | raise TypeError("argument must be string, int or file object") 44 | 45 | def _add_ns(item, ns): 46 | if ns is None: 47 | raise TypeError("namespace must not be None") 48 | if ns == _NO_NS: 49 | return item 50 | return "%s.%s" % (ns, item) 51 | 52 | def getxattr(item, attribute, nofollow=False): 53 | options = nofollow and XATTR_NOFOLLOW or 0 54 | return _call(item, _getxattr, _fgetxattr, attribute, 0, 0, options) 55 | 56 | def get(item, name, nofollow=False, namespace=_NO_NS): 57 | name = _add_ns(name, namespace) 58 | return getxattr(item, name, nofollow=nofollow) 59 | 60 | def get_all(item, nofollow=False, namespace=_NO_NS): 61 | if namespace is not None and namespace != _NO_NS: 62 | namespace = '%s.' % namespace 63 | l = listxattr(item, nofollow=nofollow) 64 | result = [] 65 | for name in l: 66 | try: 67 | if namespace is not None and namespace != _NO_NS: 68 | if not name.startswith(namespace): 69 | continue 70 | result.append((name[len(namespace):], 71 | getxattr(item, name, nofollow=nofollow))) 72 | else: 73 | result.append((name, getxattr(item, name, nofollow=nofollow))) 74 | except IOError: 75 | pass 76 | return result 77 | 78 | def setxattr(item, name, value, flags=0, nofollow=False): 79 | options = nofollow and XATTR_NOFOLLOW or 0 80 | options |= flags 81 | return _call(item, _setxattr, _fsetxattr, name, value, 0, options) 82 | 83 | def set(item, name, value, nofollow=False, flags=0, namespace=_NO_NS): 84 | name = _add_ns(name, namespace) 85 | return setxattr(item, name, value, flags=flags, nofollow=nofollow) 86 | 87 | def removexattr(item, name, nofollow=False): 88 | options = nofollow and XATTR_NOFOLLOW or 0 89 | return _call(item, _removexattr, _fremovexattr, name, options) 90 | 91 | def remove(item, name, nofollow=False, namespace=_NO_NS): 92 | name = _add_ns(name, namespace) 93 | return removexattr(item, name, nofollow=nofollow) 94 | 95 | def listxattr(item, nofollow=False): 96 | options = nofollow and XATTR_NOFOLLOW or 0 97 | res = _call(item, _listxattr, _flistxattr, options).split(b'\x00') 98 | res.pop() 99 | return res 100 | 101 | def list(item, nofollow=False, namespace=_NO_NS): 102 | if not namespace or namespace == _NO_NS: 103 | return listxattr(item, nofollow=nofollow) 104 | namespace = "%s." % namespace 105 | l = listxattr(item, nofollow=nofollow) 106 | result = [] 107 | for name in l: 108 | if not name.startswith(namespace): 109 | continue 110 | result.append(name[len(namespace):]) 111 | return result 112 | -------------------------------------------------------------------------------- /modules/common/mac_alias/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.pyc 3 | .DS_Store 4 | __pycache__ 5 | .idea 6 | *.sublime-project 7 | *.sublime-workspace 8 | ._* 9 | *.tar.gz 10 | *.tar 11 | *.csv 12 | *.json -------------------------------------------------------------------------------- /modules/common/mac_alias/__init__.py: -------------------------------------------------------------------------------- 1 | from .alias import * 2 | from .bookmark import * 3 | 4 | __all__ = [ 'ALIAS_KIND_FILE', 'ALIAS_KIND_FOLDER', 5 | 'ALIAS_HFS_VOLUME_SIGNATURE', 6 | 'ALIAS_FIXED_DISK', 'ALIAS_NETWORK_DISK', 'ALIAS_400KB_FLOPPY_DISK', 7 | 'ALIAS_800KB_FLOPPY_DISK', 'ALIAS_1_44MB_FLOPPY_DISK', 8 | 'ALIAS_EJECTABLE_DISK', 9 | 'ALIAS_NO_CNID', 10 | 'kBookmarkPath', 'kBookmarkCNIDPath', 'kBookmarkFileProperties', 11 | 'kBookmarkFileName', 'kBookmarkFileID', 'kBookmarkFileCreationDate', 12 | 'kBookmarkTOCPath', 'kBookmarkVolumePath', 13 | 'kBookmarkVolumeURL', 'kBookmarkVolumeName', 'kBookmarkVolumeUUID', 14 | 'kBookmarkVolumeSize', 'kBookmarkVolumeCreationDate', 15 | 'kBookmarkVolumeProperties', 'kBookmarkContainingFolder', 16 | 'kBookmarkUserName', 'kBookmarkUID', 'kBookmarkWasFileReference', 17 | 'kBookmarkCreationOptions', 'kBookmarkURLLengths', 18 | 'kBookmarkSecurityExtension', 19 | 'AppleShareInfo', 20 | 'VolumeInfo', 21 | 'TargetInfo', 22 | 'Alias', 23 | 'Bookmark', 24 | 'Data', 25 | 'URL' ] 26 | 27 | 28 | -------------------------------------------------------------------------------- /modules/common/mac_alias/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | 4 | import datetime 5 | 6 | ZERO = datetime.timedelta(0) 7 | class UTC (datetime.tzinfo): 8 | def utcoffset(self, dt): 9 | return ZERO 10 | def dst(self, dt): 11 | return ZERO 12 | def tzname(self, dt): 13 | return 'UTC' 14 | 15 | utc = UTC() 16 | mac_epoch = datetime.datetime(1904,1,1,0,0,0,0,utc) 17 | unix_epoch = datetime.datetime(1970,1,1,0,0,0,0,utc) 18 | osx_epoch = datetime.datetime(2001,1,1,0,0,0,0,utc) 19 | -------------------------------------------------------------------------------- /modules/common/xattr/compat.py: -------------------------------------------------------------------------------- 1 | """Python 3 compatibility shims 2 | """ 3 | import os 4 | import sys 5 | import codecs 6 | 7 | if sys.version_info[0] < 3: 8 | integer_types = (int, long) 9 | text_type = unicode 10 | binary_type = str 11 | else: 12 | integer_types = (int,) 13 | text_type = str 14 | binary_type = bytes 15 | 16 | fs_encoding = sys.getfilesystemencoding() 17 | fs_errors = 'strict' 18 | if fs_encoding != 'mbcs': 19 | try: 20 | codecs.lookup('surrogateescape') 21 | fs_errors = 'surrogateescape' 22 | except LookupError: 23 | pass 24 | try: 25 | fs_encode = os.fsencode 26 | except AttributeError: 27 | def fs_encode(val): 28 | if not isinstance(val, bytes): 29 | return val.encode(fs_encoding, fs_errors) 30 | else: 31 | return val 32 | -------------------------------------------------------------------------------- /modules/common/xattr/lib.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from .compat import fs_encode 5 | 6 | try: 7 | from ._lib import lib, ffi 8 | except ImportError: 9 | from .lib_build import ffi, c_source 10 | lib = ffi.verify(c_source) 11 | 12 | XATTR_NOFOLLOW = lib.XATTR_XATTR_NOFOLLOW 13 | XATTR_CREATE = lib.XATTR_XATTR_CREATE 14 | XATTR_REPLACE = lib.XATTR_XATTR_REPLACE 15 | XATTR_NOSECURITY = lib.XATTR_XATTR_NOSECURITY 16 | XATTR_MAXNAMELEN = lib.XATTR_MAXNAMELEN 17 | 18 | XATTR_FINDERINFO_NAME = "com.apple.FinderInfo" 19 | XATTR_RESOURCEFORK_NAME = "com.apple.ResourceFork" 20 | 21 | 22 | def _check_bytes(val): 23 | if not isinstance(val, bytes): 24 | raise TypeError( 25 | "Value must be bytes, %s was passed." % type(val).__name__ 26 | ) 27 | 28 | 29 | def error(path=None): 30 | errno = ffi.errno 31 | strerror = os.strerror(ffi.errno) 32 | if path: 33 | raise IOError(errno, strerror, path) 34 | else: 35 | raise IOError(errno, strerror) 36 | 37 | 38 | def _getxattr(path, name, size=0, position=0, options=0): 39 | """ 40 | getxattr(path, name, size=0, position=0, options=0) -> str 41 | """ 42 | path = fs_encode(path) 43 | name = fs_encode(name) 44 | if size == 0: 45 | res = lib.xattr_getxattr(path, name, ffi.NULL, 0, position, options) 46 | if res == -1: 47 | raise error(path) 48 | size = res 49 | buf = ffi.new("char[]", size) 50 | res = lib.xattr_getxattr(path, name, buf, size, position, options) 51 | if res == -1: 52 | raise error(path) 53 | return ffi.buffer(buf)[:res] 54 | 55 | 56 | def _fgetxattr(fd, name, size=0, position=0, options=0): 57 | """ 58 | fgetxattr(fd, name, size=0, position=0, options=0) -> str 59 | """ 60 | name = fs_encode(name) 61 | if size == 0: 62 | res = lib.xattr_fgetxattr(fd, name, ffi.NULL, 0, position, options) 63 | if res == -1: 64 | raise error() 65 | size = res 66 | buf = ffi.new("char[]", size) 67 | res = lib.xattr_fgetxattr(fd, name, buf, size, position, options) 68 | if res == -1: 69 | raise error() 70 | return ffi.buffer(buf)[:res] 71 | 72 | 73 | def _setxattr(path, name, value, position=0, options=0): 74 | """ 75 | setxattr(path, name, value, position=0, options=0) -> None 76 | """ 77 | _check_bytes(value) 78 | path = fs_encode(path) 79 | name = fs_encode(name) 80 | res = lib.xattr_setxattr(path, name, value, len(value), position, options) 81 | if res: 82 | raise error(path) 83 | 84 | 85 | def _fsetxattr(fd, name, value, position=0, options=0): 86 | """ 87 | fsetxattr(fd, name, value, position=0, options=0) -> None 88 | """ 89 | _check_bytes(value) 90 | name = fs_encode(name) 91 | res = lib.xattr_fsetxattr(fd, name, value, len(value), position, options) 92 | if res: 93 | raise error() 94 | 95 | 96 | def _removexattr(path, name, options=0): 97 | """ 98 | removexattr(path, name, options=0) -> None 99 | """ 100 | path = fs_encode(path) 101 | name = fs_encode(name) 102 | res = lib.xattr_removexattr(path, name, options) 103 | if res: 104 | raise error(path) 105 | 106 | 107 | def _fremovexattr(fd, name, options=0): 108 | """ 109 | fremovexattr(fd, name, options=0) -> None 110 | """ 111 | name = fs_encode(name) 112 | res = lib.xattr_fremovexattr(fd, name, options) 113 | if res: 114 | raise error() 115 | 116 | 117 | def _listxattr(path, options=0): 118 | """ 119 | listxattr(path, options=0) -> str 120 | """ 121 | path = fs_encode(path) 122 | res = lib.xattr_listxattr(path, ffi.NULL, 0, options) 123 | if res == -1: 124 | raise error(path) 125 | elif res == 0: 126 | return b"" 127 | buf = ffi.new("char[]", res) 128 | res = lib.xattr_listxattr(path, buf, res, options) 129 | if res == -1: 130 | raise error(path) 131 | return ffi.buffer(buf)[:res] 132 | 133 | 134 | def _flistxattr(fd, options=0): 135 | """ 136 | flistxattr(fd, options=0) -> str 137 | """ 138 | res = lib.xattr_flistxattr(fd, ffi.NULL, 0, options) 139 | if res == -1: 140 | raise error() 141 | buf = ffi.new("char[]", res) 142 | res = lib.xattr_flistxattr(fd, buf, res, options) 143 | if res == -1: 144 | raise error() 145 | return ffi.buffer(buf)[:res] 146 | -------------------------------------------------------------------------------- /modules/common/xattr/lib_build.h: -------------------------------------------------------------------------------- 1 | #define XATTR_XATTR_NOFOLLOW ... 2 | #define XATTR_XATTR_CREATE ... 3 | #define XATTR_XATTR_REPLACE ... 4 | #define XATTR_XATTR_NOSECURITY ... 5 | #define XATTR_MAXNAMELEN ... 6 | 7 | ssize_t xattr_getxattr(const char *, const char *, void *, ssize_t, uint32_t, int); 8 | ssize_t xattr_fgetxattr(int, const char *, void *, ssize_t, uint32_t, int); 9 | 10 | ssize_t xattr_setxattr(const char *, const char *, void *, ssize_t, uint32_t, int); 11 | ssize_t xattr_fsetxattr(int, const char *, void *, ssize_t, uint32_t, int); 12 | 13 | ssize_t xattr_removexattr(const char *, const char *, int); 14 | ssize_t xattr_fremovexattr(int, const char *, int); 15 | 16 | ssize_t xattr_listxattr(const char *, char *, size_t, int); 17 | ssize_t xattr_flistxattr(int, char *, size_t, int); 18 | -------------------------------------------------------------------------------- /modules/common/xattr/lib_build.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | from cffi import FFI 4 | 5 | PATH = os.path.dirname(__file__) 6 | 7 | with open(os.path.join(PATH, 'lib_build.h')) as hf: 8 | c_header = hf.read() 9 | with open(os.path.join(PATH, 'lib_build.c')) as cf: 10 | c_source = cf.read() 11 | 12 | ffi = FFI() 13 | ffi.cdef(c_header) 14 | ffi.set_source('_lib', c_source) 15 | 16 | if __name__ == '__main__': 17 | ffi.compile() 18 | -------------------------------------------------------------------------------- /modules/common/xattr/pyxattr_compat.py: -------------------------------------------------------------------------------- 1 | """ 2 | pyxattr and xattr have differing API, for example xattr assumes 3 | that (like on OSX) attribute keys are valid UTF-8, while pyxattr 4 | just passes through the raw bytestring. 5 | 6 | This module provides compatibility for the pyxattr API. 7 | """ 8 | 9 | import sys 10 | 11 | from .compat import (binary_type, integer_types, text_type) 12 | from .lib import (XATTR_NOFOLLOW, XATTR_CREATE, XATTR_REPLACE, 13 | XATTR_NOSECURITY, XATTR_MAXNAMELEN, XATTR_FINDERINFO_NAME, 14 | XATTR_RESOURCEFORK_NAME, _getxattr, _fgetxattr, _setxattr, _fsetxattr, 15 | _removexattr, _fremovexattr, _listxattr, _flistxattr) 16 | 17 | __all__ = [ 18 | "NS_SECURITY", "NS_USER", "NS_SYSTEM", "NS_TRUSTED", 19 | "getxattr", "get", "get_all", "setxattr", "set", 20 | "removexattr", "remove", "listxattr", "list" 21 | ] 22 | 23 | NS_SECURITY = "security" 24 | NS_USER = "user" 25 | NS_SYSTEM = "system" 26 | NS_TRUSTED = "trusted" 27 | 28 | _NO_NS = object() 29 | 30 | _fsencoding = sys.getfilesystemencoding() 31 | 32 | def _call(item, name_func, fd_func, *args): 33 | if isinstance(item, integer_types): 34 | return fd_func(item, *args) 35 | elif hasattr(item, 'fileno'): 36 | return fd_func(item.fileno(), *args) 37 | elif isinstance(item, binary_type): 38 | return name_func(item, *args) 39 | elif isinstance(item, text_type): 40 | item = item.encode(_fsencoding) 41 | return name_func(item, *args) 42 | else: 43 | raise TypeError("argument must be string, int or file object") 44 | 45 | def _add_ns(item, ns): 46 | if ns is None: 47 | raise TypeError("namespace must not be None") 48 | if ns == _NO_NS: 49 | return item 50 | return "%s.%s" % (ns, item) 51 | 52 | def getxattr(item, attribute, nofollow=False): 53 | options = nofollow and XATTR_NOFOLLOW or 0 54 | return _call(item, _getxattr, _fgetxattr, attribute, 0, 0, options) 55 | 56 | def get(item, name, nofollow=False, namespace=_NO_NS): 57 | name = _add_ns(name, namespace) 58 | return getxattr(item, name, nofollow=nofollow) 59 | 60 | def get_all(item, nofollow=False, namespace=_NO_NS): 61 | if namespace is not None and namespace != _NO_NS: 62 | namespace = '%s.' % namespace 63 | l = listxattr(item, nofollow=nofollow) 64 | result = [] 65 | for name in l: 66 | try: 67 | if namespace is not None and namespace != _NO_NS: 68 | if not name.startswith(namespace): 69 | continue 70 | result.append((name[len(namespace):], 71 | getxattr(item, name, nofollow=nofollow))) 72 | else: 73 | result.append((name, getxattr(item, name, nofollow=nofollow))) 74 | except IOError: 75 | pass 76 | return result 77 | 78 | def setxattr(item, name, value, flags=0, nofollow=False): 79 | options = nofollow and XATTR_NOFOLLOW or 0 80 | options |= flags 81 | return _call(item, _setxattr, _fsetxattr, name, value, 0, options) 82 | 83 | def set(item, name, value, nofollow=False, flags=0, namespace=_NO_NS): 84 | name = _add_ns(name, namespace) 85 | return setxattr(item, name, value, flags=flags, nofollow=nofollow) 86 | 87 | def removexattr(item, name, nofollow=False): 88 | options = nofollow and XATTR_NOFOLLOW or 0 89 | return _call(item, _removexattr, _fremovexattr, name, options) 90 | 91 | def remove(item, name, nofollow=False, namespace=_NO_NS): 92 | name = _add_ns(name, namespace) 93 | return removexattr(item, name, nofollow=nofollow) 94 | 95 | def listxattr(item, nofollow=False): 96 | options = nofollow and XATTR_NOFOLLOW or 0 97 | res = _call(item, _listxattr, _flistxattr, options).split(b'\x00') 98 | res.pop() 99 | return res 100 | 101 | def list(item, nofollow=False, namespace=_NO_NS): 102 | if not namespace or namespace == _NO_NS: 103 | return listxattr(item, nofollow=nofollow) 104 | namespace = "%s." % namespace 105 | l = listxattr(item, nofollow=nofollow) 106 | result = [] 107 | for name in l: 108 | if not name.startswith(namespace): 109 | continue 110 | result.append(name[len(namespace):]) 111 | return result 112 | -------------------------------------------------------------------------------- /modules/common/xattr/tests/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import unittest 4 | 5 | 6 | def all_tests_suite(): 7 | suite = unittest.TestLoader().loadTestsFromNames([ 8 | 'xattr.tests.test_xattr', 9 | ]) 10 | return suite 11 | 12 | 13 | def main(): 14 | runner = unittest.TextTestRunner() 15 | suite = all_tests_suite() 16 | runner.run(suite) 17 | 18 | 19 | if __name__ == '__main__': 20 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) 21 | main() 22 | -------------------------------------------------------------------------------- /modules/common/xmltodict/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrowdStrike/automactc/0df8d738be5f3e5053c4a6facda4014ea8ba4b36/modules/common/xmltodict/__init__.py -------------------------------------------------------------------------------- /modules/mod_bash.py: -------------------------------------------------------------------------------- 1 | """A module intended to read and parse .*_history and .bash_sessions 2 | files for each user on the machine, including the root user. 3 | """ 4 | 5 | import logging 6 | import io 7 | import sys 8 | from collections import OrderedDict 9 | 10 | # IMPORT STATIC VARIABLES FROM MAIN 11 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 12 | inputdir, no_tarball, outputdir, quiet, startTime) 13 | 14 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 15 | from .common.functions import multiglob, stats2 16 | 17 | _modName = __name__.split('_')[-1] 18 | _modVers = '1.0.3' 19 | log = logging.getLogger(_modName) 20 | 21 | 22 | def module(): 23 | _headers = ['mtime', 'atime', 'ctime', 'btime', 24 | 'src_file', 'user', 'item_index', 'cmd'] 25 | output = data_writer(_modName, _headers) 26 | 27 | user_inputdir = multiglob(inputdir, ['Users/*/.*_history', 'Users/*/.bash_sessions/*', 28 | 'private/var/*/.*_history', 'private/var/*/.bash_sessions/*',]) 29 | 30 | # Generate debug messages indicating users with history files to be parsed. 31 | userlist = [] 32 | for file in user_inputdir: 33 | userpath = file.split('/') 34 | if 'Users' in userpath: 35 | userindex = len(userpath) - 1 - userpath[::-1].index('Users') + 1 36 | else: 37 | userindex = len(userpath) - 1 - userpath[::-1].index('var') + 1 38 | user = userpath[userindex] 39 | 40 | userlist.append(user) 41 | 42 | for u in list(set(userlist)): 43 | log.debug("Going to parse bash and other history under {0} user.".format(u)) 44 | 45 | # Parse history files found. 46 | for file in user_inputdir: 47 | # Get username from path. 48 | userpath = file.split('/') 49 | if 'Users' in userpath: 50 | userindex = len(userpath) - 1 - userpath[::-1].index('Users') + 1 51 | else: 52 | userindex = len(userpath) - 1 - userpath[::-1].index('var') + 1 53 | user = userpath[userindex] 54 | 55 | # Parse the files. 56 | out = stats2(file) 57 | if sys.version_info[0] < 3: 58 | sess = io.open(file, 'r', encoding='ascii', errors='ignore').readlines() 59 | else: 60 | sess = open(file, 'r', encoding='ascii', errors="surrogateescape").readlines() 61 | indexer = 0 62 | for line in sess: 63 | record = OrderedDict((h, '') for h in _headers) 64 | 65 | for i in _headers: 66 | if i in out: 67 | record[i] = out[i] 68 | record['src_file'] = out['name'] 69 | 70 | record['user'] = user 71 | record['cmd'] = line.rstrip() 72 | indexer += 1 73 | record['item_index'] = indexer 74 | output.write_record(record) 75 | output.flush_record() 76 | 77 | if __name__ == "__main__": 78 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 79 | print("Exiting.") 80 | sys.exit(0) 81 | else: 82 | module() 83 | -------------------------------------------------------------------------------- /modules/mod_installhistory.py: -------------------------------------------------------------------------------- 1 | """A module intended to parse the InstallHistory.plist file. 2 | """ 3 | 4 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 5 | from .common.functions import stats2 6 | 7 | # IMPORT STATIC VARIABLES FROM MAIN 8 | from __main__ import inputdir 9 | from __main__ import outputdir 10 | from __main__ import forensic_mode 11 | from __main__ import no_tarball 12 | from __main__ import quiet 13 | 14 | from __main__ import archive 15 | from __main__ import startTime 16 | from __main__ import full_prefix 17 | from __main__ import data_writer 18 | 19 | import plistlib 20 | import logging 21 | import os 22 | import glob 23 | import sys 24 | from collections import OrderedDict 25 | 26 | _modName = __name__.split('_')[-1] 27 | _modVers = '1.0.2' 28 | log = logging.getLogger(_modName) 29 | 30 | 31 | def module(): 32 | headers = ['src_name', 'timestamp', 'display_name', 'display_version', 33 | 'package_identifiers', 'process_name'] 34 | output = data_writer(_modName, headers) 35 | 36 | installhistory_loc = os.path.join(inputdir, 'Library/Receipts/InstallHistory.plist') 37 | installhistory_list = glob.glob(installhistory_loc) 38 | 39 | if len(installhistory_list) == 0: 40 | log.debug("File not found: {0}".format(installhistory_loc)) 41 | 42 | for file in installhistory_list: 43 | installhistoryfile = open(file, 'rb') 44 | try: 45 | installhistory = plistlib.load(installhistoryfile) 46 | except AttributeError as e: 47 | log.debug(e) 48 | log.debug("Running python 2 code for this.") 49 | installhistory = plistlib.readPlist(installhistoryfile) 50 | 51 | for i in range(len(installhistory)): 52 | record = OrderedDict((h, '') for h in headers) 53 | record['src_name'] = os.path.basename(file) 54 | if 'date' in installhistory[i]: 55 | record['timestamp'] = installhistory[i]['date'].strftime('%Y-%m-%dT%H:%M:%SZ') 56 | else: 57 | record['timestamp'] = "" 58 | if 'displayVersion' in installhistory[i]: 59 | record['display_version'] = installhistory[i]['displayVersion'] 60 | else: 61 | record['display_version'] = "" 62 | if 'displayName' in installhistory[i]: 63 | record['display_name'] = installhistory[i]['displayName'] 64 | else: 65 | record['display_name'] = "" 66 | if 'packageIdentifiers' in installhistory[i]: 67 | record['package_identifiers'] = installhistory[i]['packageIdentifiers'] 68 | else: 69 | record['package_idenfifiers'] = "" 70 | if 'processName' in installhistory[i]: 71 | record['process_name'] = installhistory[i]['processName'] 72 | else: 73 | record['process_name'] = "" 74 | 75 | output.write_record(record) 76 | output.flush_record() 77 | 78 | 79 | if __name__ == "__main__": 80 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 81 | print("Exiting.") 82 | sys.exit(0) 83 | else: 84 | module() 85 | -------------------------------------------------------------------------------- /modules/mod_live_1_pslist.py: -------------------------------------------------------------------------------- 1 | """A module intended to record the current process listing when run on a 2 | live system. 3 | """ 4 | 5 | import logging 6 | import os 7 | import subprocess 8 | import sys 9 | 10 | # IMPORT STATIC VARIABLES FROM MAIN 11 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 12 | inputdir, no_tarball, outputdir, quiet, startTime) 13 | 14 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 15 | from .common.dateutil import parser 16 | from .common.functions import stats2 17 | 18 | _modName = __name__.split('_')[-1] 19 | _modVers = '1.1.0' 20 | log = logging.getLogger(_modName) 21 | 22 | 23 | def module(): 24 | if ("Volumes" not in inputdir and forensic_mode is False): 25 | headers = ['pid', 'ppid', 'user', 'state', 'proc_start', 'runtime', 'cmd'] 26 | output = data_writer(_modName, headers) 27 | 28 | os.environ['TZ'] = 'UTC0' 29 | ps_out, e = subprocess.Popen(["ps", "-Ao", "pid,ppid,user,stat,lstart,time,command"], stdout=subprocess.PIPE).communicate() 30 | 31 | if e: 32 | pass 33 | else: 34 | pslist = ps_out.decode('utf-8').split('\n') 35 | for p in pslist: 36 | if "PID" not in p and len(p) > 0: 37 | item = [x.lstrip(' ') for x in filter(None, p.split(' '))] 38 | pid = item[0] 39 | ppid = item[1] 40 | user = item[2] 41 | state = item[3] 42 | proc_start = parser.parse(' '.join(item[5:9])).replace(tzinfo=None).isoformat() + 'Z' 43 | runtime = item[9] 44 | cmd = ' '.join(item[10:]) 45 | 46 | line = [pid, ppid, user, state, proc_start, runtime, cmd] 47 | output.write_record(line) 48 | 49 | else: 50 | log.error("Module did not run: input is not a live system!") 51 | output.flush_record() 52 | 53 | if __name__ == "__main__": 54 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 55 | print("Exiting.") 56 | sys.exit(0) 57 | else: 58 | module() 59 | -------------------------------------------------------------------------------- /modules/mod_live_2_lsof.py: -------------------------------------------------------------------------------- 1 | """A module intended to record current file handles open, when run on a 2 | live system. 3 | """ 4 | 5 | import logging 6 | import sys 7 | from collections import OrderedDict 8 | from subprocess import PIPE, Popen 9 | 10 | # IMPORT STATIC VARIABLES FROM MAIN 11 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 12 | inputdir, no_tarball, outputdir, quiet, startTime) 13 | 14 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 15 | from .common.functions import stats2 16 | 17 | _modName = __name__.split('_')[-1] 18 | _modVers = '1.1.0' 19 | log = logging.getLogger(_modName) 20 | 21 | 22 | def module(): 23 | if ("Volumes" not in inputdir and forensic_mode is False): 24 | headers = ['cmd', 'pid', 'ppid', 'user', 'file_descriptor', 'type', 'device', 'size', 'node', 'access', 'name'] 25 | output = data_writer(_modName, headers) 26 | 27 | # encoding = locale.getpreferredencoding(True) 28 | names = OrderedDict(zip('cpRLftDsian', 'command pid ppid user fd type device_no size inode access name'.split())) 29 | 30 | lsof = Popen(["lsof", "-n", "-P", "-F{}0".format(''.join(names))], stdout=PIPE, bufsize=-1) 31 | 32 | for line in lsof.stdout: 33 | try: 34 | fields = {f[:1].decode('ascii', 'strict'): f[1:].decode() for f in line.split(b'\0') if f.rstrip(b'\n')} 35 | except UnicodeDecodeError: 36 | fields = {f[:1].decode('ascii', 'strict'): f[1:] for f in line.split(b'\0') if f.rstrip(b'\n')} 37 | if 'p' in fields: 38 | process_info = fields 39 | elif 'f' in fields: 40 | fields.update(process_info) 41 | result = OrderedDict((name, fields.get(id)) for id, name in names.items()) 42 | line = [v for k, v in result.items()] 43 | 44 | output.write_record(line) 45 | 46 | lsof.communicate() 47 | else: 48 | log.error("Module did not run: input is not a live system!") 49 | output.flush_record() 50 | 51 | if __name__ == "__main__": 52 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 53 | print("Exiting.") 54 | sys.exit(0) 55 | else: 56 | module() 57 | -------------------------------------------------------------------------------- /modules/mod_live_3_netstat.py: -------------------------------------------------------------------------------- 1 | """A module intended to record current and past network connections, when 2 | run on a live system. 3 | """ 4 | 5 | import logging 6 | import subprocess 7 | import sys 8 | 9 | # IMPORT STATIC VARIABLES FROM MAIN 10 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 11 | inputdir, no_tarball, outputdir, quiet, startTime) 12 | 13 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 14 | from .common.functions import stats2 15 | 16 | _modName = __name__.split('_')[-1] 17 | _modVers = '1.1.0' 18 | log = logging.getLogger(_modName) 19 | 20 | 21 | def module(): 22 | if ("Volumes" not in inputdir and forensic_mode is False): 23 | 24 | headers = ['protocol', 'recv_q', 'send_q', 'src_ip', 'src_port', 'dst_ip', 'dst_port', 'state'] 25 | output = data_writer(_modName, headers) 26 | 27 | netstat_out, e = subprocess.Popen(["netstat", "-f", "inet", "-n"], stdout=subprocess.PIPE).communicate() 28 | 29 | if e: 30 | pass 31 | else: 32 | netstat = netstat_out.decode().split('\n') 33 | for l in netstat: 34 | if not (l.startswith("Active") or l.startswith("Proto") or len(l) == 0): 35 | item = [x.lstrip(' ') for x in filter(None, l.split(' '))] 36 | protocol = item[0] 37 | recv_q = item[1] 38 | send_q = item[2] 39 | 40 | try: 41 | src_ip = '.'.join(item[3].split('.')[0:4]) 42 | except Exception: 43 | src_ip = "ERROR" 44 | try: 45 | src_port = item[3].split('.')[-1] 46 | except Exception: 47 | src_port = "ERROR" 48 | 49 | try: 50 | dst_ip = '.'.join(item[4].split('.')[0:4]) 51 | except Exception: 52 | dst_ip = "ERROR" 53 | try: 54 | dst_port = item[4].split('.')[-1] 55 | except Exception: 56 | dst_port = "ERROR" 57 | 58 | if len(item) == 6: 59 | state = item[5] 60 | else: 61 | state = "" 62 | 63 | line = [protocol, recv_q, send_q, src_ip, src_port, dst_ip, dst_port, state] 64 | output.write_record(line) 65 | 66 | else: 67 | log.error("Module did not run: input is not a live system!") 68 | output.flush_record() 69 | 70 | if __name__ == "__main__": 71 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 72 | print("Exiting.") 73 | sys.exit(0) 74 | else: 75 | module() 76 | -------------------------------------------------------------------------------- /modules/mod_live_4_unifiedlogs.py: -------------------------------------------------------------------------------- 1 | """A module intended to collect Unified Logging events from a live system 2 | based on specified predicates using the log show command. 3 | """ 4 | 5 | import logging 6 | import os 7 | import subprocess 8 | import sys 9 | 10 | # IMPORT STATIC VARIABLES FROM MAIN 11 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 12 | inputdir, no_tarball, outputdir, quiet, startTime) 13 | 14 | _modName = __name__.split('_')[-1] 15 | _modVers = '1.0.3' 16 | log = logging.getLogger(_modName) 17 | 18 | 19 | def module(): 20 | if forensic_mode: 21 | log.error("Module did not run: input is not a live system!") 22 | return 23 | 24 | output = data_writer("unifiedlogs_live", None) 25 | 26 | predicates = [ 27 | 'process == "sudo" && eventMessage CONTAINS[c] "User=root" && (NOT eventMessage CONTAINS[c] "root : PWD=/ ; USER=root") && (NOT eventMessage CONTAINS[c] " root : PWD=")', # Captures command line activity run with elevated privileges 28 | # 'process == "logind"', # Captures user login events < Large 29 | # 'process == "tccd"', # Captures events that indicate permissions and access violations < Very Large 30 | 'process == "sshd" ', # Captures successful, failed and general ssh activity 31 | # '(process == "kextd" && sender == "IOKit")', # Captures successful and failed attempts to add kernel extensions < Large 32 | '(process == "screensharingd" || process == "ScreensharingAgent")', # Captures events that indicate successful or failed authentication via screen sharing 33 | # '(process == "loginwindow" && sender == "Security")', # Captures keychain.db unlock events < Large 34 | '(process == "securityd" && eventMessage CONTAINS "Session" && subsystem == "com.apple.securityd")', # Captures session creation and destruction events 35 | ] 36 | predicate = ' OR '.join(predicates) 37 | predicate = "'" + predicate + "'" 38 | 39 | cmd = 'log show --info --backtrace --debug --loss --signpost --style ndjson --force --timezone UTC --predicate' 40 | outcmd = '> {0}'.format(output.data_file_name.split(output.datatype)[0] + 'json') 41 | 42 | cmd = cmd + " " + predicate + " " + outcmd 43 | 44 | log.debug("Collecting Unified Logs via {0}".format(cmd)) 45 | 46 | if sys.version_info[0] < 3: 47 | outbytes = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate() 48 | out = outbytes[0].decode('utf-8').split('\n') 49 | else: 50 | outbytes = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) 51 | out = outbytes.stdout.decode('utf-8').split('\n') 52 | if "Bad predicate" in out[0]: 53 | log.debug("command was: {0}".format(cmd)) 54 | raise Exception("Failed to collect unified logs: {0}".format(out[0])) 55 | 56 | if output.datatype == "csv": 57 | log.debug('converting unified logs output to csv') 58 | from .common import json_to_csv 59 | json_to_csv.json_file_to_csv(output.data_file_name.split(output.datatype)[0] + 'json') 60 | os.remove(output.data_file_name.split(output.datatype)[0] + 'json') 61 | elif output.datatype == "all": 62 | log.debug('converting unified logs output to csv') 63 | from .common import json_to_csv 64 | json_to_csv.json_file_to_csv(output.data_file_name.split(output.datatype)[0] + 'json') 65 | 66 | 67 | if __name__ == "__main__": 68 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 69 | print("Exiting.") 70 | sys.exit(0) 71 | else: 72 | module() 73 | -------------------------------------------------------------------------------- /modules/mod_netconfig.py: -------------------------------------------------------------------------------- 1 | """A module intended parse network config plists 2 | """ 3 | 4 | import logging 5 | import os 6 | import plistlib 7 | import re 8 | import sys 9 | from collections import OrderedDict 10 | 11 | # IMPORT STATIC VARIABLES FROM MAIN 12 | from __main__ import (OSVersion, archive, data_writer, forensic_mode, 13 | full_prefix, inputdir, outputdir, quiet, startTime) 14 | 15 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 16 | from .common.functions import finditem 17 | 18 | _modName = __name__.split('_')[-1] 19 | _modVers = '1.0.1' 20 | log = logging.getLogger(_modName) 21 | 22 | 23 | def module(): 24 | _headers = ['type', 'name', 'last_connected', 'security', 'hotspot'] 25 | _output = data_writer(_modName, _headers) 26 | 27 | if sys.version_info[0] < 3: 28 | airport = plistlib.readPlist(os.path.join(inputdir, 'Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist')) 29 | interface = plistlib.readPlist(os.path.join(inputdir, 'Library/Preferences/SystemConfiguration/NetworkInterfaces.plist')) 30 | else: 31 | with open(os.path.join(inputdir, 'Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist'), 'rb') as fp: 32 | airport = plistlib.load(fp) 33 | with open(os.path.join(inputdir, 'Library/Preferences/SystemConfiguration/NetworkInterfaces.plist'), 'rb') as fp: 34 | interface = plistlib.load(fp) 35 | 36 | # KEEP THE LINE BELOW TO GENERATE AN ORDEREDDICT BASED ON THE HEADERS 37 | record = OrderedDict((h, '') for h in _headers) 38 | 39 | if 'KnownNetworks' in airport: 40 | for i in airport['KnownNetworks']: 41 | record['type'] = "Airport" 42 | record['name'] = finditem(airport['KnownNetworks'][i], 'SSIDString') 43 | record['last_connected'] = finditem(airport['KnownNetworks'][i], 'LastConnected') 44 | record['security'] = finditem(airport['KnownNetworks'][i], 'SecurityType') 45 | record['hotspot'] = finditem(airport['KnownNetworks'][i], 'PersonalHotspot') 46 | 47 | _output.write_record(record) 48 | else: 49 | log.debug("No KnownNetworks found") 50 | 51 | if 'Interfaces' in interface: 52 | for i in interface['Interfaces']: 53 | record['type'] = finditem(i, 'BSD Name') 54 | record['name'] = finditem(i['SCNetworkInterfaceInfo'], 'UserDefinedName') 55 | record['last_connected'] = '' 56 | record['security'] = '' 57 | record['hotspot'] = '' 58 | 59 | _output.write_record(record) 60 | else: 61 | log.debug("No Interfaces found") 62 | _output.flush_record() 63 | 64 | 65 | if __name__ == "__main__": 66 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 67 | print("Exiting.") 68 | sys.exit(0) 69 | else: 70 | module() 71 | -------------------------------------------------------------------------------- /modules/mod_quarantines.py: -------------------------------------------------------------------------------- 1 | """A module intended to parse the QuarantineEventsV2 database. 2 | """ 3 | 4 | 5 | import logging 6 | import sys 7 | from collections import OrderedDict 8 | 9 | # IMPORT STATIC VARIABLES FROM MAIN 10 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 11 | inputdir, no_tarball, outputdir, quiet, startTime) 12 | 13 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 14 | from .common.functions import cocoa_time, multiglob, query_db 15 | 16 | _modName = __name__.split('_')[-1] 17 | _modVers = '1.0.3' 18 | log = logging.getLogger(_modName) 19 | 20 | 21 | def module(): 22 | headers = ['user', 'timestamp', 'bundle_id', 'quarantine_agent', 'download_url', 'sender_name', 23 | 'sender_address', 'typeno', 'origin_title', 'origin_title', 'origin_url', 'origin_alias'] 24 | output = data_writer(_modName, headers) 25 | 26 | qevents_list = multiglob(inputdir, ['Users/*/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2', 27 | 'private/var/*/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2']) 28 | qry = 'SELECT * FROM LSQuarantineEvent' 29 | 30 | if len(qevents_list) == 0: 31 | log.debug("Files not found in: {0}".format(qevents_list)) 32 | 33 | for i in qevents_list: 34 | data = query_db(i, qry, outputdir) 35 | 36 | userpath = i.split('/') 37 | if 'Users' in userpath: 38 | userindex = len(userpath) - 1 - userpath[::-1].index('Users') + 1 39 | else: 40 | userindex = len(userpath) - 1 - userpath[::-1].index('var') + 1 41 | user = userpath[userindex] 42 | 43 | for item in data: 44 | item = list(item) 45 | record = OrderedDict((h, '') for h in headers) 46 | record['user'] = user 47 | record['timestamp'] = cocoa_time(item[1]) 48 | record['bundle_id'] = item[2] 49 | record['quarantine_agent'] = item[3] 50 | record['download_url'] = item[4] 51 | record['sender_name'] = item[5] 52 | record['sender_address'] = item[6] 53 | record['typeno'] = str(item[7]) 54 | record['origin_title'] = item[8] 55 | record['origin_url'] = item[9] 56 | record['origin_alias'] = item[10] 57 | 58 | output.write_record(record) 59 | output.flush_record() 60 | 61 | 62 | if __name__ == "__main__": 63 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 64 | print("Exiting.") 65 | sys.exit(0) 66 | else: 67 | module() 68 | -------------------------------------------------------------------------------- /modules/mod_quicklook.py: -------------------------------------------------------------------------------- 1 | """A module intended to parse the Quicklooks database for each user. 2 | """ 3 | 4 | import glob 5 | import io 6 | import logging 7 | import os 8 | import sys 9 | import traceback 10 | from collections import OrderedDict 11 | 12 | # IMPORT STATIC VARIABLES FROM MAIN 13 | from __main__ import (OSVersion, archive, data_writer, forensic_mode, 14 | full_prefix, inputdir, no_tarball, outputdir, quiet, 15 | startTime) 16 | 17 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 18 | from .common import ccl_bplist as bplist 19 | from .common.functions import cocoa_time, query_db, read_stream_bplist, stats2 20 | 21 | _modName = __name__.split('_')[-1] 22 | _modVers = '1.0.2' 23 | log = logging.getLogger(_modName) 24 | 25 | 26 | def module(): 27 | headers = ['uid', 'path', 'name', 'last_hit_date', 'hit_count', 28 | 'file_last_modified', 'generator', 'file_size'] 29 | output = data_writer(_modName, headers) 30 | 31 | q_loc = os.path.join(inputdir, 'private/var/folders/*/*/C/com.apple.QuickLook.thumbnailcache/index.sqlite') 32 | qlist = glob.glob(q_loc) 33 | 34 | if OSVersion is not None: 35 | ver = float('.'.join(OSVersion.split('.')[1:])) 36 | if ver > 14.0 and ver is not None and forensic_mode is not True: 37 | log.error("Artifacts are inaccessible on and above OS version 10.14 on live systems.") 38 | return 39 | else: 40 | if forensic_mode is not True: 41 | log.debug("OSVersion not detected, but going to try to parse anyway.") 42 | else: 43 | log.error("OSVersion not detected, so will not risk parsing as artifacts are inaccessible on and above OS version 10.14 on live systems.") 44 | return 45 | 46 | if len(qlist) == 0: 47 | log.debug("Files not found in: {0}".format(q_loc)) 48 | 49 | ql_sql = 'SELECT distinct k.folder, k.file_name, t.hit_count, t.last_hit_date, k.version \ 50 | FROM (SELECT rowid AS f_rowid,folder,file_name,version FROM files) k \ 51 | LEFT JOIN thumbnails t ON t.file_id = k.f_rowid ORDER BY t.hit_count DESC' 52 | 53 | for qfile in qlist: 54 | 55 | uid = stats2(qfile)['uid'] 56 | 57 | data = query_db(qfile, ql_sql, outputdir) 58 | 59 | for item in data: 60 | item = list(item) 61 | 62 | record = OrderedDict((h, '') for h in headers) 63 | record['uid'] = uid 64 | record['path'] = item[0] 65 | record['name'] = item[1] 66 | 67 | if item[3]: 68 | record['last_hit_date'] = cocoa_time(item[3]) 69 | else: 70 | record['last_hit_date'] = '' 71 | 72 | if item[2]: 73 | record['hit_count'] = item[2] 74 | else: 75 | record['hit_count'] = '' 76 | 77 | try: 78 | try: 79 | plist_array = read_stream_bplist(item[4]) 80 | except Exception: 81 | plist_array = bplist.load(io.BytesIO(item[4])) 82 | record['file_last_modified'] = cocoa_time(plist_array['date']) 83 | record['generator'] = plist_array['gen'] 84 | try: 85 | record['file_size'] = int(plist_array['size']) 86 | except KeyError: 87 | record['file_size'] = 'Error' 88 | except Exception: 89 | log.error("Could not parse: embedded binary plist for record {0}".format(record['name'])) 90 | 91 | output.write_record(record) 92 | output.flush_record() 93 | 94 | if __name__ == "__main__": 95 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 96 | print("Exiting.") 97 | sys.exit(0) 98 | else: 99 | module() 100 | -------------------------------------------------------------------------------- /modules/mod_spotlight.py: -------------------------------------------------------------------------------- 1 | """A module intended to parse the com.apple.spotlight.Shortcuts plist file, 2 | which contains a record of every application opened with Spotlight, as 3 | well as the timestamp that it was last opened. 4 | """ 5 | 6 | import logging 7 | import plistlib 8 | import sys 9 | 10 | # IMPORT STATIC VARIABLES FROM MAIN 11 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 12 | inputdir, no_tarball, outputdir, quiet, startTime) 13 | 14 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 15 | from .common.functions import multiglob 16 | 17 | _modName = __name__.split('_')[-1] 18 | _modVers = '1.0.3' 19 | log = logging.getLogger(_modName) 20 | 21 | 22 | def module(): 23 | headers = ['user', 'shortcut', 'display_name', 'last_used', 'url'] 24 | output = data_writer(_modName, headers) 25 | 26 | user_inputdir = multiglob(inputdir, ['Users/*/Library/Application Support/com.apple.spotlight.Shortcuts', 27 | 'private/var/*/Library/Application Support/com.apple.spotlight.Shortcuts']) 28 | 29 | for file in user_inputdir: 30 | userpath = file.split('/') 31 | if 'Users' in userpath: 32 | userindex = len(userpath) - 1 - userpath[::-1].index('Users') + 1 33 | else: 34 | userindex = len(userpath) - 1 - userpath[::-1].index('var') + 1 35 | user = userpath[userindex] 36 | 37 | log.debug("Going to parse Spotlight shortcuts under {0} user.".format(user)) 38 | try: 39 | if sys.version_info[0] < 3: 40 | spotlight_data = plistlib.readPlist(file) 41 | else: 42 | spotlight_data = plistlib.load(file) 43 | for k, v in spotlight_data.items(): 44 | shortcut = k 45 | display_name = spotlight_data[k]['DISPLAY_NAME'] 46 | last_used = spotlight_data[k]['LAST_USED'].isoformat() + "Z" 47 | url = spotlight_data[k]['URL'] 48 | 49 | line_raw = [user, shortcut, display_name, last_used, url] 50 | line = [x for x in line_raw] 51 | 52 | output.write_record(line) 53 | 54 | except Exception: 55 | log.error("Could not parse: {0}".format(file)) 56 | 57 | output.flush_record() 58 | 59 | 60 | if __name__ == "__main__": 61 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 62 | print("Exiting.") 63 | sys.exit(0) 64 | else: 65 | module() 66 | -------------------------------------------------------------------------------- /modules/mod_ssh.py: -------------------------------------------------------------------------------- 1 | """A module intended to read and parse SSH known_hosts and authorized_keys 2 | files for each user on disk. 3 | """ 4 | 5 | import glob 6 | import logging 7 | import os 8 | import subprocess 9 | import sys 10 | from collections import OrderedDict 11 | 12 | # IMPORT STATIC VARIABLES FROM MAIN 13 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 14 | inputdir, no_tarball, outputdir, quiet, startTime) 15 | 16 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 17 | from .common.functions import multiglob, stats2 18 | 19 | _modName = __name__.split('_')[-1] 20 | _modVers = '1.0.3' 21 | log = logging.getLogger(_modName) 22 | 23 | 24 | def module(): 25 | known_hosts_headers = ['src_name', 'user', 'bits', 'fingerprint', 'host', 'keytype'] 26 | output = data_writer(_modName, known_hosts_headers) 27 | 28 | user_inputdir = multiglob(inputdir, ["Users/*/.ssh", "private/var/*/.ssh"]) 29 | 30 | record = OrderedDict((h, '') for h in known_hosts_headers) 31 | 32 | for user_home in user_inputdir: 33 | record['user'] = user_home.split('/')[-2] 34 | 35 | # Gather known_hosts and authorized_users files for the user. 36 | kh_path = os.path.join(user_home, 'known_hosts') 37 | u_knownhosts = glob.glob(kh_path) 38 | 39 | ak_path = os.path.join(user_home, 'authorized_keys') 40 | u_authorizedkeys = glob.glob(ak_path) 41 | 42 | # Combine all files found into one list per user. 43 | u_ssh_all = u_knownhosts + u_authorizedkeys 44 | 45 | # Define the directory checked for use in debug messages. 46 | user_ssh_dir = os.path.join(user_home, '.ssh/') 47 | 48 | # Generate debug messages for files not found. 49 | if len(u_knownhosts) == 0: 50 | log.debug("File not found: {0}".format(kh_path)) 51 | if len(u_authorizedkeys) == 0: 52 | log.debug("File not found: {0}".format(ak_path)) 53 | 54 | # Iterate over files found and parse them using ssh-keygen. 55 | for file in u_ssh_all: 56 | p, e = subprocess.Popen(["ssh-keygen", "-l", "-f", file], stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate() 57 | record['src_name'] = os.path.basename(file) 58 | 59 | if not e and not "is not a public key file" in p.decode('utf-8'): 60 | p = p.decode('utf-8').split('\n') 61 | p = [x for x in p if len(x) > 0] 62 | for i in p: 63 | data = i.split(' ') 64 | record['bits'] = data[0] 65 | record['fingerprint'] = data[1] 66 | record['host'] = data[2] 67 | record['keytype'] = data[3] 68 | 69 | output.write_record(record) 70 | 71 | elif "is not a public key file" in p: 72 | log.debug("Could not parse {0}: {1}".format(file, p)) 73 | 74 | output.flush_record() 75 | 76 | 77 | if __name__ == "__main__": 78 | print("This is an AutoMacTC module, and is not meant to be run stand-alone.") 79 | print("Exiting.") 80 | sys.exit(0) 81 | else: 82 | module() 83 | -------------------------------------------------------------------------------- /modules/mod_syslog.py: -------------------------------------------------------------------------------- 1 | """A module intended to read and parse system.log files on disk. 2 | """ 3 | 4 | import glob 5 | import gzip 6 | import logging 7 | import os 8 | import re 9 | import sys 10 | from collections import OrderedDict 11 | 12 | # IMPORT STATIC VARIABLES FROM MAIN 13 | from __main__ import (archive, data_writer, forensic_mode, full_prefix, 14 | inputdir, no_tarball, outputdir, quiet, startTime) 15 | 16 | # IMPORT FUNCTIONS FROM COMMON.FUNCTIONS 17 | from .common.functions import stats2 18 | from .common.dateutil import parser 19 | 20 | try: 21 | from builtins import range as xrange 22 | except Exception: 23 | pass 24 | 25 | 26 | _modName = __name__.split('_')[-1] 27 | _modVers = '1.0.1' 28 | log = logging.getLogger(_modName) 29 | 30 | 31 | def syslog_parse(logfile, logdata, headers, output): 32 | x = 0 33 | data = [] 34 | singlelines = {} 35 | multilines = {} 36 | for i in logdata: 37 | x += 1 38 | if (not isinstance(i, str)): 39 | if re.search('^[A-Za-z]{3}'.encode('utf-8'), i): 40 | singlelines[x] = i.rstrip() 41 | else: 42 | data.append(x) 43 | data.append(x - 1) 44 | data.append(x + 1) 45 | multilines[x] = i.rstrip() 46 | else: 47 | if re.search('^[A-Za-z]{3}', i): 48 | singlelines[x] = i.rstrip() 49 | else: 50 | data.append(x) 51 | data.append(x - 1) 52 | data.append(x + 1) 53 | multilines[x] = i.rstrip() 54 | 55 | data = list(OrderedDict.fromkeys(sorted(data))) 56 | ranges = [] 57 | # for key, group in groupby(enumerate(data), lambda (index, item): index - item): 58 | for group in enumerate(data): 59 | # group = map(itemgetter(1), group) 60 | if len(group) > 1: 61 | ranges.append(xrange(group[0], group[-1])) 62 | else: 63 | ranges.append(group[0]) 64 | 65 | for u in ranges: 66 | chain = [] 67 | for z in u: 68 | if multilines.get(z) is None: 69 | lno = z 70 | anchor = singlelines.get(z) 71 | else: 72 | if (not isinstance(multilines.get(z), str)): 73 | val = multilines.get(z).decode('utf-8').replace('\t', '').replace(' ', '') 74 | else: 75 | val = multilines.get(z).replace('\t', '').replace(' ', '') 76 | chain.append(val) 77 | if (isinstance(anchor, str)): 78 | singlelines[lno] = anchor + ' ' + ''.join(chain) 79 | else: 80 | singlelines[lno] = anchor.decode('utf-8') + ' ' + ''.join(chain) 81 | 82 | for k, v in singlelines.items(): 83 | line = v 84 | if (not isinstance(line, str)): 85 | line = line.decode('utf-8') 86 | if 'last message repeated' not in line: 87 | record = OrderedDict((h, '') for h in headers) 88 | m = re.match(r"(?P\w\w\w)\s{1,2}(?P\d{1,2}) (?P