ScanOcr¶
Extracts optical text from image files and (optionally) generates a thumbnail using OCR (Optical Character Recognition).
This scanner processes image files and PDFs (if enabled), extracting text content via OCR. It can also generate a thumbnail for the image. This is useful for analyzing document images and scanned PDFs to extract textual data for further analysis.
Scanner Type: Collection
Attributes:
Name | Type | Description |
---|---|---|
event |
dict
|
Stores extracted text and thumbnail data during the scan. |
Detection Use Cases¶
Detection Use Cases
- Text Extraction
- Extract text from images and scanned documents for content analysis and pattern matching.
- Thumbnail Generation
- Generate a visual summary of the document for quick reference.
Known Limitations¶
Known Limitations
- Image Quality Dependence
- OCR accuracy heavily depends on the quality and clarity of the input image.
- Issues Observed From Image Corruption
- Images observed to be corrupt from the source or processing will throw errors and fail to scan.
To Do¶
To Do
- Enhance PDF handling to support OCR on all pages.
Contributors¶
Contributors
Source code in strelka/src/python/strelka/scanners/scan_ocr.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
scan(data, file, options, expire_at)
¶
Scans the given data for text using OCR and optionally generates a thumbnail.
The function handles image files directly and can convert PDFs to images if enabled. Extracted text and generated thumbnails are stored in the event dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
Data of the file being scanned. |
required |
file |
File
|
File object being scanned. |
required |
options |
dict
|
Options for the scanner. |
required |
expire_at |
datetime
|
Expiration time of the scan result. |
required |
Source code in strelka/src/python/strelka/scanners/scan_ocr.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
Features¶
The features of this scanner are detailed below. These features represent the capabilities and the type of analysis the scanner can perform. This may include support for Indicators of Compromise (IOC), the ability to emit files for further analysis, and the presence of extended documentation for complex analysis techniques.
Feature | Support |
---|---|
IOC Support |
|
Emit Files |
|
Extended Docs |
|
Malware Scanner |
|
Image Thumbnails |
Tastes¶
Strelka's file distribution system assigns scanners to files based on 'flavors' and 'tastes'. Flavors describe the type of file, typically determined by MIME types from libmagic, matches from YARA rules, or characteristics of parent files. Tastes are the criteria used within Strelka to determine which scanners are applied to which files, with positive and negative tastes defining files to be included or excluded respectively.
Source Filetype | Include / Exclude |
---|---|
application/pdf |
|
bmp_file |
|
gif_file |
|
image/gif |
|
image/jpeg |
|
image/png |
|
image/tiff |
|
image/webp |
|
image/x-ms-bmp |
|
jpeg_file |
|
pdf_file |
|
png_file |
|
type_is_tiff |
Scanner Fields¶
This section provides a list of fields that are extracted from the files processed by this scanner. These fields include the data elements that the scanner extracts from each file, representing the analytical results produced by the scanner. If the test file is missing or cannot be parsed, this section will not contain any data.
Field Name | Field Type |
---|---|
base64_thumbnail |
str |
elapsed |
str |
flags |
list |
render |
dict |
render.dpi |
int |
render.format |
str |
render.height |
int |
render.source |
str |
render.width |
int |
text |
list |
Sample Event¶
Below is a sample event generated by this scanner, demonstrating the kind of output that can be expected when it processes a file. This sample is derived from a mock scan event configured in the scanner's test file. If no test file is available, this section will not display a sample event.
test_scan_event = {
"elapsed": 0.001,
"flags": [],
"render": {
"dpi": 300,
"format": "png",
"height": 590,
"source": "pdf",
"width": 928,
},
"text": [
b"Lorem",
b"Ipsum",
b"Lorem",
b"ipsum",
b"dolor",
b"sit",
b"amet,",
b"consectetur",
b"adipiscing",
b"elit.",
b"Cras",
b"lobortis",
b"sem",
b"dui.",
b"Morbi",
b"at",
b"magna",
b"quis",
b"ligula",
b"faucibus",
b"consectetur",
b"feugiat",
b"at",
b"purus.",
b"Sed",
b"nec",
b"lorem",
b"nibh.",
b"Nam",
b"vel",
b"libero",
b"odio.",
b"Vivamus",
b"tempus",
b"non",
b"enim",
b"egestas",
b"pretium.",
b"Vestibulum",
b"turpis",
b"arcu,",
b"maximus",
b"nec",
b"libero",
b"quis,",
b"imperdiet",
b"suscipit",
b"purus.",
b"Vestibulum",
b"blandit",
b"quis",
b"lacus",
b"non",
b"sollicitudin.",
b"Nullam",
b"non",
b"convallis",
b"dui,",
b"et",
b"aliquet",
b"risus.",
b"Sed",
b"accumsan",
b"ullamcorper",
b"vehicula.",
b"Proin",
b"non",
b"urna",
b"facilisis,",
b"condimentum",
b"eros",
b"quis,",
b"suscipit",
b"purus.",
b"Morbi",
b"euismod",
b"imperdiet",
b"neque",
b"fermentum",
b"dictum.",
b"Integer",
b"aliquam,",
b"erat",
b"sit",
b"amet",
b"fringilla",
b"tempus,",
b"mauris",
b"ligula",
b"blandit",
b"sapien,",
b"et",
b"varius",
b"sem",
b"mauris",
b"eu",
b"diam.",
b"Sed",
b"fringilla",
b"neque",
b"est,",
b"in",
b"laoreet",
b"felis",
b"tristique",
b"in.",
b"Donec",
b"luctus",
b"velit",
b"a",
b"posuere",
b"posuere.",
b"Suspendisse",
b"sodales",
b"pellentesque",
b"quam.",
],
}